User Registration compress to use less querry, CPU posible I want to find out if there are any improvements I can make to this code. How can I make it better, faster and use less queries? Or is it fine the way I wrote it?

&lt;?php if ( $user_ID ) : ?&gt;
&lt;?php
global $user_identity;
?&gt;
&lt;div id="boxtop"&gt;
&lt;div class="boxtop"&gt;
&lt;div class="bus"&gt;
&lt;div class="busl"&gt;
&lt;span class="bin"&gt;
Bine ai revenit&lt;a href="/edit-profile/"&gt;&lt;b&gt;&lt;?php echo $user_identity; ?&gt;&lt;/b&gt; !&lt;/a&gt;
&lt;/span&gt;
&lt;?php 
global $current_user;
$current_user = wp_get_current_user();
?&gt;

&lt;a href="/utilizatori-inregstrati/"&gt;Utilizatori&lt;/a&gt;|&lt;a href="/edit-profile/"&gt;Profil&lt;/a&gt;|&lt;a href="&lt;?php echo wp_logout_url( get_bloginfo('url') ); ?&gt;" title="Logout"&gt;Logout&lt;/a&gt;
&lt;/div&gt;
&lt;div class="busr"&gt;
&lt;?php 
$current_user = wp_get_current_user();
if ( ($current_user instanceof WP_User) ) {
    echo get_avatar( $current_user-&gt;user_email, 40 );
}
?&gt;
&lt;/div&gt;
&lt;/div&gt;
 &lt;/div&gt;
&lt;/div&gt;
&lt;?php else : ?&gt;

&lt;div id="boxtop"&gt;
&lt;div class="boxtop"&gt;
&lt;a class="fblogin" href="http://www.mysite.ro/wp-login.php?loginFacebook=1&amp;redirect=http://www.mysite.ro" onclick="window.location = 'http://www.mysite.ro/wp-login.php?loginFacebook=1&amp;redirect='+window.location.href; return false;"&gt;&lt;img src="/wp-content/themes/movies/images/fb.png" title="Login with Facebook"  /&gt;&lt;/a&gt;
&lt;form name="loginform" id="loginform" action="&lt;?php echo get_option('siteurl'); ?&gt;/wp-login.php" method="post"&gt;
&lt;input value="Utilizator" class="input" type="text" size="10" tabindex="10" name="log" id="user_login" onfocus="if (this.value == 'Utilizator') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Utilizator';}" /&gt;
&lt;input value="Parola" class="input" type="password" size="10" tabindex="20" name="pwd" id="user_pass" onfocus="if (this.value == 'Parola') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Parola';}" /&gt;
&lt;input name="wp-submit" id="wp-submit" value="Login" tabindex="100" type="submit"&gt;
&lt;span class="bin"&gt;
&lt;span&gt;&lt;a href="/recupereaza-parola/"&gt;Recuperare parola&lt;/a&gt;&lt;/span&gt;&lt;span&gt;&lt;a href="/inregistrare/"&gt;Inregistrare&lt;/a&gt;&lt;/span&gt;&lt;input name="rememberme" id="rememberme" value="forever" tabindex="90" type="checkbox"&gt; &lt;span&gt;Retine parola?&lt;/span&gt;
&lt;/span&gt;
&lt;input name="redirect_to" value="&lt;?php echo get_option('siteurl'); ?&gt;" type="hidden"&gt;
&lt;input name="testcookie" value="1" type="hidden"&gt;
&lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;?php endif; ?&gt;
Ok, a few things of note. Not really related to perfomance, but readability. To be fair though these are just details for better readability,  your code is not so bad.

This code is not expensive process wise, I was curious as to where $User_id comes from, because that is where the query you are worried about comes into play, but I trust your tables are properly indexed and output data is properly escaped.

On line 12-14,  I would put that php code up at top, all in a single php block.
This would separate the php from the html and make for better readability.

Also, same thing for the php block on line 21.  You call once again $current_user = wp_get_current_user(); , but you already have $current_user from line 15. 

I would take this block to the top, and change the echo get_avatar() call to :

$avatar = "";
if ( ($current_user instanceof WP_User) ) {
  $avatar =  get_avatar( $current_user-&gt;user_email, 40 );
} 


By initialising the variable (best practice), in your html "template code" below you can get away with just:

if ($avatar) { print $avatar; }


This habit leaves minimal php in the html and thus separates the logic from presentation.

I assume indentation was lost when you pasted, so I will not patronize you on this.

Hope this helps, happy coding.