Conditional for Gravatar versus no Gravatar


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

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 ...

$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
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).