• Resolved adrianhanft

    (@adrianhanft)


    Can someone help me with something I am trying to do on my blog? When an author is logged in, I would like to show his/her gravatar in the sidebar along with some of their profile information. I am new to WordPress (from Movable Type) and don’t have a good grasp on the php of WordPress yet. Here is the code that I have tried without success:


    My Gravatar: <?php if (function_exists('gravatar')) {
    echo "<img src='";
    echo gravatar($curauth->user-email);
    echo "' alt='' class='gravatar' />";}
    ?>

    and


    My Gravatar: <?php if (function_exists('gravatar')) {
    $user_gravatar = wp_gravatar($curauth->user-email);

    echo "<img src='$user_gravatar' />";}
    ?>

    It seems like it should work, but then again I don’t know what I am doing. Thanks for your help in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter adrianhanft

    (@adrianhanft)

    I eventually got this to work. If anyone has a similar problem I recommend you upgrade to Gravatar2 and then use this code:


    <?php if (function_exists('gravatar')) { gravatar_image($userdata->user_email); } ?>

    Thread Starter adrianhanft

    (@adrianhanft)

    Actually the code above wasn’t quite right. Try this:


    <?php global $user_email;
    get_currentuserinfo();

    gravatar_image($user_email);

    ?>

    Can anyone inform me how to get some user info and place beside the gravatar?

    Thread Starter adrianhanft

    (@adrianhanft)

    carnold,

    I am probably the last person that should be giving advice about php and wordpress, but here is the code I used on my sidebar. It gives the user info (and gravatar) for the user who is signed in. On my site you have to sign in before you can see anything on the blog, so this works as a “my profile” type of feature. I hope it helps. Please somebody with more experience chime in because I can’t elaborate on this at all. Sorry!

    <h2><?php global $userdata; get_currentuserinfo();
    echo($userdata->first_name);
    echo " ";
    echo($userdata->last_name); ?></h2>

    <?php global $user_email;
    get_currentuserinfo();
    echo "<img src='";
    echo gravatar($user_email);
    echo "' alt='' class='gravatar' width='80' height='80' ALIGN=RIGHT />";
    ?>

    carnold

    (@carnold)

    humm, this gets me my name and nickname. The rest of your code did not show up right. Can you repaste that here with spaces between the php code (like < ? php and so on). Many thanks
    OR
    send me the code via email to carnold5 at gmail dot com

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Gravatar for Current User in Sidebar’ is closed to new replies.