• I did a search but couldn’t find the answer.

    I’m using the gravatar plugin for my comments and it works great. I have created user profile pages and I’m trying to do some different things with them because at the moment, they’re pretty boring. – You can see my user profile page here: https://heather-anne.com/?author=1

    I’m trying to add gravatars to the page. Right now I have the same code from my comments placed on the page:

    <img src=”<?php gravatar(“R”, 80, “https://heather-anne.com/images/defaulticon.png&#8221;); ?>” class=”gravatar” />

    But all I’m getting is my default gravatar.

    I know I’m missing something, but I can’t figure it out (and I just don’t have the time to sit here and play with codes.)

    Any suggestions?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    The gravatar plugin is *specifically* looking at the comment author’s email address. You can’t just use it for anything.

    You’ll have to modify the plugin to be able to use it for other purposes than comments.

    Thread Starter hpnotiq

    (@hpnotiq)

    Any suggestions on how to do that?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Add this to your gravatar.php plugin, just before the end ?> marker (assuming you’re using the normal plugin from gravatar.com):


    function gravatar_by_email($rating = false, $size = false, $default = false, $border = false, $email="") {
    $out = "https://www.gravatar.com/avatar.php?gravatar_id=".md5($email);
    if($rating && $rating != '')
    $out .= "&amp;rating=".$rating;
    if($size && $size != '')
    $out .="&amp;size=".$size;
    if($default && $default != '')
    $out .= "&amp;default=".urlencode($default);
    if($border && $border != '')
    $out .= "&amp;border=".$border;
    echo $out;
    }

    Now, change your author template to call gravatar_by_email() instead of gravatar(), and add a new parameter to end of the function call which is that person’s email address. If you’re using code from the codex, this will be $curauth->user_email.

    This will let it get their gravatar.

    just use the plugin runphp on your page in one of the side boxes it should say runphp with a tick box under it click it then your gravatar should work

    I’m having the same issue.

    Otto, I edited the gravatar.php per your instructions, but I don’t know how to change teh author template as you suggest. This is probably a dumb question, but I’m a relatively new WordPress user, so I plead ignorance. Your help would be greatly appreciated!

    Otto42- Thanks for the primer. I’ve got the avatar appearing in my author page, but as of yet it’s the default gravatar image and not personalized. I know that’s because I haven’t defined gravatar_by_email yet. The problem is, I don’t know where to define it or how.

    Forgive my php ignorance (just know enough to break something) but if you could be a little more explicit I would be very grateful.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Gravatars on user profiles’ is closed to new replies.