Support » Plugin: Site Reviews » compatibility with WP User Avatar plugin

  • Resolved andrew55

    (@andrew55)


    Greetings,

    Most of our website visitors don’t use gravatar, but we would love to have their uploaded avatars next to their reviews. This gives much more credibility to the reviews, which is so important these days.

    So users can upload custom avatars, we have the popular “WP User Avatar” plugin installed:

    https://wordpress.org/plugins/wp-user-avatar/

    …but as you can see on our test website page, your review plugin doesn’t seem to be compatible with “WP User Avatar” plugin.

    On the first test review, user had avatar uploaded before review was made. When I inspecting the code, your plugin seems to strip out the slashes which breaks the avatar image.

    On the second test review, user did not had avatar uploaded before review was made. When avatar was loaded after review was made, the avatar image was not updated (should be new image, not standard avatar image that is shown).

    Any ideas on how to get your plug working properly with WP User Avatar? Thanks for any suggestions.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    1. Site Reviews uses the native WordPress get_avatar_url function to get the avatar URL. However, the plugin you mention fails to filter this function like it does to all the other native WordPress avatar related functions. This is why the avatars are not working. The exact same issue was reported here: https://wordpress.org/support/topic/elementor-and-the-get_avatar_url-function/

    As suggested in that topic, you can fix this by adding the missing filter yourself to your theme’s functions.php file. However, if you do this I recommend that you use the following code which is better than the one in the link above as it verifies that the plugin is active before attempting to use the plugin functions:

    /**
     * Fixes the "WP User Avatar" plugin which does not filter the "get_avatar_url" function
     * @param string $url
     * @param string|int $id_or_email
     * @return string
     */
    add_filter( 'get_avatar_url', function( $url, $id_or_email ) {
        if( !function_exists( 'has_wp_user_avatar' ) || !function_exists( 'get_wp_user_avatar_src' )) {
            return $url;
        }
        if( is_email( $id_or_email )) {
            $user = get_user_by( 'email', $id_or_email );
            $id_or_email = isset( $user->ID )
                ? $user->ID
                : '';
        }
        return has_wp_user_avatar( $id_or_email )
            ? get_wp_user_avatar_src( $id_or_email )
            : $url;
    }, 10, 2 );

    Alternatively, you can install and use the similar WP User Avatars plugin instead which filters the “get_avatar_url” function correctly and works “out-of-the-box”.

    2. If you need the avatar to regenerate whenever an avatar is changed, please enable the “Regenerate Avatars” option in the Site Reviews settings.

    • This reply was modified 9 months, 2 weeks ago by Gemini Labs.

    Works great now. Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘compatibility with WP User Avatar plugin’ is closed to new replies.