• Resolved millonario

    (@millonario)


    Hello, I have custom avatars .. and the problem is that with your plugin my avatars shows by default how WordPress has it, but users have them customized (Upload their own photos) I have noticed that if the code is user_id it shows wrong the avatars, shows the default wordpress, but if user_email correctly shows the avatars, the question is .. through functions I can change avatars are based on the user’s email?

    If I enter this code in my template, the avatars are shown as they should:

    echo get_avatar(get_the_author_meta(‘user_email‘), ’88’);

    If I enter it like this, it shows the avatar that comes by default with wordpress:

    echo get_avatar(get_the_author_meta(‘user_id‘), ’88’);

    Thank you so much

    • This topic was modified 6 years, 9 months ago by millonario.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    1. Firstly, you are using get_the_author_meta in the second example incorrectly

    // This is incorrect
    echo get_avatar(get_the_author_meta('user_id'), '88');
    
    // It should be:
    echo get_avatar(get_the_author_meta('ID'), '88');
    

    See: https://developer.www.ads-software.com/reference/functions/get_the_author_meta/

    2. It seems we started this on a different topic but never finished it: https://www.ads-software.com/support/topic/small-problem-with-avatars/

    Do each of these give the same image URL result on your site (they should!)?

    echo get_avatar( get_current_user_id(), 37 );
    echo get_avatar_url( get_current_user_id(), ['size' => 37] );
    

    Site Reviews uses get_avatar_url( $review->email ); to get the avatar of the reviewer. If a user changes their email on WordPress, it will not change on the review so that avatar will remain unchanged as it will always use the avatar associated with the email that was initially saved to the review.

    However, you can change this by pasting the code in this link to your active theme’s functions.php file. This code will automatically regenerate an avatar whenever a review is displayed: https://pastebin.com/zNxAr6U4

    3. Please do not past raw HTML code in the support forums without using the “code” button on the editor toolbar.

    Otherwise, you will mess up the support page as what happened here: https://www.ads-software.com/support/topic/small-problem-with-avatars/

    • This reply was modified 6 years, 9 months ago by Gemini Labs.
    • This reply was modified 6 years, 9 months ago by Gemini Labs.
    • This reply was modified 6 years, 9 months ago by Gemini Labs.
    Thread Starter millonario

    (@millonario)

    I want to apologize, for making so many mistakes in the forum, I did not know that the HTML is accepted here .. when I realized, I tried to edit it but the edit button does not appear … if someone could delete my annoying message I would appreciate it.

    I also thank the author for the patience he has with a novice like me ..

    Regarding question 2, it does not show me the same result of capture:

    https://image.ibb.co/hPqydT/borrar_fw.png

    Plugin Author Gemini Labs

    (@geminilabs)

    It looks like whichever plugin you are using to allow custom avatars is not hooking into the WordPress get_avatar_url function correctly like it’s supposed to.

    Did the pastebin link in #2 fix the problem for you?

    If not, please download your System Info report (Site Reviews > Get Help > System Info > Download system info) and send it to site-reviews[at]geminilabs[dot]io

    Thanks

    • This reply was modified 6 years, 9 months ago by Gemini Labs.
    • This reply was modified 6 years, 9 months ago by Gemini Labs.
    • This reply was modified 6 years, 9 months ago by Gemini Labs.
    Thread Starter millonario

    (@millonario)

    Hello, I tried the code and did not change anything, followed the steps you indicated and sent an email ..

    Plugin Author Gemini Labs

    (@geminilabs)

    This is not an issue with Site Reviews.

    WP User Frontend stores the custom avatar in a “user_avatar” User meta_key. They use the WordPress “get_avatar” filter hook to replace the avatar with the custom one, however, they don’t use the WordPress “get_avatar_data” filter hook which is why get_avatar() works but get_avatar_url() (which is what Site Reviews uses) does not.

    I suggest you raise a support request for them to fix this. Until then, here is a quick fix (add to your theme’s functions.php file):

    add_filter( 'get_avatar_data', function( $args, $id_or_email ) {
        if( $user_id = get_the_author_meta( 'ID', $id_or_email )) {
            $custom_avatar_url = get_user_meta( $user_id, 'user_avatar', true );
        }
        if( !empty( $custom_avatar_url )) {
            $args['url'] = $custom_avatar_url;
        }
        return $args;
    }, 10, 2 );
    

    @itowhid06
    @rabbii
    @rafsuntaskin
    @skshaikat
    @tareq1988
    @thebengalboy
    @wedevs

    • This reply was modified 6 years, 9 months ago by Gemini Labs.
    Thread Starter millonario

    (@millonario)

    Thank you very much, you are great .. unfortunately I did not funtion the code you gave me but anyway I left a message to wp frontend user to update it in the next update … Thank you so much for worrying about me

    Plugin Author Gemini Labs

    (@geminilabs)

    Are you sure you put the code in your active theme’s functions.php file?

    I was able to duplicate the issue on my side and the above fix works for me here on the WordPress twenty-seventeen theme.

    Note: You will need to still use the code in the pastebin link a few posts above along with this fix. Site Reviews v3.0 will provide an option to regenerate avatars when they are displayed, but until then you will need to use the pastebin code.

    Thread Starter millonario

    (@millonario)

    I just added the previous code, and it works perfectly for me. Thank you so much .. you are the best

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to change Avatars from ID to Email?’ is closed to new replies.