Don't update avatar if default

I’m testing implementing SSO with WP as my provider but it automatically changes users avatars to the default avatar on my site (basically the site logo), is it possible to not bring the avatar across and just use the Discourse letters if the user has the default?

Are you using a plugin for avatars, or are you using the default WordPress Gravatar avatars? When the default WordPress Gravatars are being used, the expected behaviour is that an avatar URL with the parameter d=404 will be passed from WordPress to Discourse during SSO login. The d=404 parameter will cause Discourse to display a letter avatar for users who have not set a Gravatar.

This is working correctly when I test it. If it’s not working correctly for you, any details about your avatar setup would be helpful.


Yep, I am using WP User Avatar which sets a default avatar. I assume that is what is causing the issue and I’d have to add something custom to ignore it?

That will be the problem. The WP Discourse plugin has a 'wpdc_sso_avatar_url' filter that can be used to filter the avatar URL that is passed to Discourse. The filter is passed two parameters: $avatar_url, and $user_id.

To avoid sending the default avatar to Discourse, you’d need to add some code to your theme’s functions.php file that hooks into the filter and returns an empty string for users who have the default avatar:

add_filter( 'wpdc_sso_avatar_url', 'wpdc_custom_sso_avatar_url', 10, 2 );
function wpdc_custom_sso_avatar_url( $avatar_url, $user_id ) {
    if ( /* some condition that returns true for users with the default avatar */ ) {

        return '';

    return $avatar_url;

That worked perfectly, thanks.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.