WordPress.org

Ready to get started?Download WordPress

Forums

Gravatars on user profiles (7 posts)

  1. hpnotiq
    Member
    Posted 7 years ago #

    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: http://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, "http://heather-anne.com/images/defaulticon.png"); ?>" 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?

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    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.

  3. hpnotiq
    Member
    Posted 7 years ago #

    Any suggestions on how to do that?

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    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 = "http://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.

  5. Seronix
    Member
    Posted 7 years ago #

    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

  6. babcock0214
    Member
    Posted 7 years ago #

    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!

  7. kimberlyhogg
    Member
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags