• Hi,

    How would I say

    IF user has gravatar then fair enough display it
    ELSEIF not then do blah blah blah??

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have something like this:

    <?php if(function_exists('get_avatar')){
      echo get_avatar($comment, '32', $default=identicon);
    } ?>

    (see it in action)

    Regarding the “identicon” see:
    https://en.blog.wordpress.com/2008/05/04/default-avatars/

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Short answer: You don’t. There is no easy way to tell if a user has a gravatar or not. The way it works is that it sticks the correct image code into the page and lets the gravatar server either serve up the gravatar or the default image.

    Thread Starter xdesi

    (@xdesi)

    OK, it’s just I have the users select from a range of avatars, and was wondering if I could display a Gravatar if they have one, if not display the one they selected on the comment form.

    I’ll just go for one or the other.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Oh. Yeah, you can do that. The third parameter to the get_avatar function is a “default” setting. If they have no avatar, then that one displays.

    Like this:
    get_avatar( $comment, 96, 'https://example.com/avatar.gif' );

    Thread Starter xdesi

    (@xdesi)

    Sorry for the delay, I understand now.

    Just one problem with my PHP skills really, how do i go about inserting a PHP statement within the default location, for example:

    $default = ‘https://www.mysite.com/print $comment->extra_avatar;.jpg’ );

    Obviously the part in bold retrieves the image name, but how do i execute this correctly? I guess I need to escape the quotes somehow?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘If Statement Help (If user does not have gravatar)’ is closed to new replies.