• Resolved nartoof

    (@nartoof)


    Hi,

    I got a problem with the avatars for non logged in user.

    I’m not sure I understand the “Regenerate avatar” option in the admin panel.

    If I set it to “no” :
    -anonymous reviews got the default gravatar in the wordpress settings.
    -all the reviews with an account and a gravatar got the mysterious avatar.
    -all the reviews with an account and no gravatar got the mysterious avatar.

    If I set it to “yes” :
    -anonymous reviews got the avatar I use as the admin of the website !!!
    -all the reviews with an account and a gravatar got their avatar correctly
    -all the reviews with an account and no gravatar got the default gravatar in the wordpress settings.

    I would like to have :
    -the custom avatar for logged in users
    -the default gravatar in wordpress settings for non logged in users (and obviously logged in users with no gravatar account).

    It is a gravatar issue or I can do something to use the default mysterious avatar with your plugin when user isn’t logged in ?

    I think I miss something with your plugin because if I post a comment with the default WordPress/Woocommerce comment form, I got the good mysterious avatar when I post as a non logged in user.

    I tried it on many browsers and in private mode on chrome. Always the same problem…

    Thank you for your help.

    Anthony

    • This topic was modified 4 years, 11 months ago by nartoof.
    • This topic was modified 4 years, 11 months ago by nartoof.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter nartoof

    (@nartoof)

    I use glsr_get_reviews() function to display all the reviews.

    Even if I try this :

    if ($review->author=='Anonymous') $review->avatar='CUSTOM IMAGE URL';

    It still display the avatar I use as the admin of the website…

    Plugin Author Gemini Labs

    (@geminilabs)

    Are you posting anonymous reviews while logged in as administrator?

    The gravatar service uses the submitted email to locate the avatar if it exists. If you have hidden the name and email fields on your review form, then Site Reviews will automatically use the display name and email of the logged in user (if a user is logged in).

    I suggest you enable the “Regenerate avatar” setting and then perform the troubleshooting steps:

    Thread Starter nartoof

    (@nartoof)

    Are you posting anonymous reviews while logged in as administrator?

    Nope, I’m not logged in when I try to post as anonymous.

    I indeed have the email and name field hidden.

    I have the latest version of your plugin, and I tried deactive all plugins and switch to a WordPress theme (I even try to reset my functions.php file).

    But there is still the same problem.

    I tried to add another form with no email and name field hidden. It works correctly in the back office for logged in user (IMAGE) and non logged in (IMAGE).

    But in frontend, I got the avatar for both logged in and non logged in (simply using your [site_reviews assigned_to=”post_id”] shortcode) : IMAGE.

    And for the form I’d like to use in a custom post type, with no name and email, It’s more weird :

    No avatar for non logged in (normal) : IMAGE
    No avatar for logged in (weird) : IMAGE (EDIT : If I don’t hide email field, the avatar is correctly displayed in the back office). So if I hide the e-mail field, site reviews find my email as logged in but does not display my gravatar…

    But in each case, in frontend I got avatar for both : IMAGE

    I just can’t find where this problem comes from…

    • This reply was modified 4 years, 11 months ago by nartoof.
    • This reply was modified 4 years, 11 months ago by nartoof.
    • This reply was modified 4 years, 11 months ago by nartoof.
    • This reply was modified 4 years, 11 months ago by nartoof.
    • This reply was modified 4 years, 11 months ago by nartoof.
    Thread Starter nartoof

    (@nartoof)

    New step :

    If I do that (with E-mail field show) :

    $reviews = glsr_get_reviews([ 'assigned_to' => get_the_ID() , 'per_page' => -1, ]);
    foreach ($reviews as $review)
    {
    $output.='<img src="' . $review->avatar . '" />'; 
    }

    It displayed the good avatar in frontend.

    But If I do that :

    $reviews = glsr_get_reviews([ 'assigned_to' => get_the_ID() , 'per_page' => -1, ]);
    foreach ($reviews as $review)
    {
    $output.= $review;
    }

    It displayed the wrong avatar.

    Here is a new screenshot with an echo of the avatar URL : IMAGE

    URL’s are good when I show email field. It’s just a display problem in the foreach loop (and same problem if I use your shortcode [site_reviews assigned_to=”post_id”].

    But when I hide the e-mail field, there is no key in the avatar URL, it might be the reason of the problem…

    EDIT : If I set regenerate avatar to “no”, the good avatar is displayed in front end only if I don’t hide the email field.
    But the key is still missing in the avatar URL if I hide the email field.

    • This reply was modified 4 years, 11 months ago by nartoof.
    Thread Starter nartoof

    (@nartoof)

    I just looked at the database, and I think the problem is when I hide the E-mail field, the avatar URL isn’t correct.

    Look at this JSON entry :

    {"author":"Anthony Hxxxxx","avatar":"https://secure.gravatar.com/avatar/?s=96&d=mm&r=g","email":"anthony.developpeur@xxxxxx","ip_address":"2a01:e35:2e76:2e10:9d70:52d3:xxxxxxxxx","rating":4}

    And the _avatar meta key is the same : https://secure.gravatar.com/avatar/?s=96&d=mm&r=g

    I’m logged in, site reviews insert my display name and my email correctly, but there is no key in the avatar URL…

    Plugin Author Gemini Labs

    (@geminilabs)

    Ah, thank you very much @nartoof, this is a bug and will be fixed in the next version.

    If you would like to patch the plugin yourself until the fix is released:

    File to change:

    /wp-content/plugins/site-reviews/plugin/Modules/Html/Partials/SiteReviews.php:L317
    

    Search for:

    $authorIdOrEmail = get_the_author_meta('ID', $this->current->user_id);
    

    Replace with:

    if ($this->current->user_id) {
        $authorIdOrEmail = get_the_author_meta('ID', $this->current->user_id);
    }
    Thread Starter nartoof

    (@nartoof)

    Thank you for your answer.

    This made me crazy I didn’t understand where the problem came from !

    I’ll patch it even if I can wait, this is for an under development website.

    And as I said each time I open a topic here, great job, I really like your plugin !

    Thank you.

    Plugin Author Gemini Labs

    (@geminilabs)

    The problem was due to the usage of the get_the_author_meta function.

    The second argument of that function expects either a user ID, or false (which is the default) in which case it uses the current logged in user ID.

    When an anonymous review is submitted, the user ID is 0. However, because PHP is a loosely-typed language, passing a user ID of 0 to the second argument of get_the_author_meta was the same as passing false which meant that it used the current logged in user ID instead.

    Thread Starter nartoof

    (@nartoof)

    Yep,

    That’s what I understood when I read the line you modify.

    Thank you for the explanation anyway ??

    Anthony

    Plugin Author Gemini Labs

    (@geminilabs)

    Fixed in v4.3.0

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Default avatar image for non logged in user’ is closed to new replies.