Add an avatar to the sidebar login

In this is example of the wpmem_sidebar_status filter hook we will add a gravatar image to the user’s sidebar login status.
The hook brings in the html $string generated by the plugin. You may use that, filter it, append to it, or anything.

This example adds a gravatar to the front of the generated $string using the WP function get_avatar. (Learn more about get_avatar in the WordPress Codex.)

Whatever you do, the filter should return what you wish to display as a string. DO NOT echo.

[php]/**
* WP-Members sidebar status filter hook
* puts a gravatar in the sidebar status
*/
add_filter( ‘wpmem_sidebar_status’, ‘my_sidebar_status’ );
function my_sidebar_status( $string )
{
// The $user_ID is needed for the get_avatar function
$user_ID = get_current_user_id();

// We are floating the gravatar to the left and a 4 pixel padding.
// The get_avatar function can define the size in pixels
$gravatar = ‘<div style="padding:4px 4px 0 0;float:left;">’
. get_avatar( $user_ID, ’46’ )
. ‘</div>’;

// The unedited html for the login status was passed
// in $string. We are adding the above html to the
// beginning of that string.
$string = $gravatar . $string;

// Return the new string
return $string;
}[/php]