I am making a wordpress site now, and I just inserted an HTML block into my sidebar. I want to to serve 2 functions. 1. If the user isn't signed in, I want it to display a login block. (working) 2. If the user is signed in, I want it to display their avatar. (not working) I looked up the get_avatar function on the wordpress site, and this is what I found. But it doesn't show anything...
My code:
[logged_out][login][/logged_out]
[logged_in]
<?php
global $current_user;
get_currentuserinfo();
echo get_avatar(ID, 128 );
?>
[/logged_in]
My question, is this because it is an HTML block, and it won't support PHP, or is something wrong with the code?
Define a shortcode in your functions.php http://codex.wordpress.org/Shortcode_API
Return
<img src="avatar_src" />
from shortcode definition Then you can use that shortcode in your text widget and add this filter to make it workinghttp://codex.wordpress.org/Function_Reference/do_shortcode