• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Conditional for Gravatar versus no Gravatar

LPH

Well-known member
#1
I have this very simple function which returns Gravatars externally from XenForo.

PHP:
function xenword_avatar ( $id_or_email ) {
    if ( ! get_option( 'show_avatars' ) ) {
        return false;
    }
    $email = $id_or_email;
    return $email;
}
add_filter('get_avatar', 'xenword_avatar', 10, 5);
The challenge is that I want the XenForo uploaded avatar to show if the member is not using a Gravatar.

I'm aware of these two ...

Code:
XenForo_Model_Avatar::gravatarExists
and
Code:
$avatar= XenForo_Upload::getUploadedFile('avatar');
But trying to wrap the return $email in either one causes nothing to show. The conditional shouldn't be reliant on the login or logout of a visitor.

Does anyone have any suggestions on where I can look to try to figure out a way to get non-Gravatars to show outside XenForo?
 

Chris D

XenForo developer
Staff member
#2
A user's Gravatar comes from the "gravatar" field in xf_user.

If that has a value (an email address), they have a gravatar, if they don't, then they have some other form of avatar (an uploaded one or a default one).