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

Discussion in 'XenForo Development Discussions' started by LPH, May 3, 2015.

  1. LPH

    LPH 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' ) ) {
    $email $id_or_email;
    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?
  2. Chris D

    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).
    LPH likes this.
  3. LPH

    LPH Well-Known Member

    @Chris D Thank you. Now I just have to figure out how to grab that field based on the $id_or_email variable. :)

Share This Page