Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a php widget, and I need to show the avatar of the current logged in user, and I'm calling this code: <?php echo get_avatar(); ?> But its only outputting the default avatar.

Is there a global I need to add above it?

share|improve this question

1 Answer 1

This should work great... in this example i am using wordpress codex so you can comapre:

From Wordpress Codex

<?php echo get_avatar( $id_or_email, $size, $default, $alt ); ?> 

so... Based on that...

This is the code you should embed in the desired location in your theme:

<?php
    wp_get_current_user();
    $size = array(60,60); // this is the size of the avatar
    echo get_avatar( $current_user->user_email, $size, $default, $current_user->display_name );
?>

.
Hope this helps :)

share|improve this answer
    
Doesn't seem to change anything. –  Jack Stewart Nov 5 '11 at 3:50
    
it should work mate.. are you sure you are logged in? hmm.. try to enter this after wp_get_current_user(); --THIS--> echo 'User email: ' . $current_user->user_email . '<br />'; –  Sagive SEO Nov 5 '11 at 4:00
    
nope. not working –  Jack Stewart Nov 5 '11 at 4:37
    
Noting echoes? not even the plain text meaning 'User email:' i guess your not pasting that code in a place that would result in the apearnce of the thumb niether the text i gave you in order to check... –  Sagive SEO Nov 5 '11 at 5:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.