Could you update user avatar for wordpress plugin sso?

SSO plugin is very good.
But it can not sync user avatar from discourse for wordpress.
Could you update for this?

1 Like

Hey @cmdntd :slight_smile:

It sounds like you have Discourse setup as the DiscourseConnect provider for Wordpress via the WP Discourse plugin? Is that right?

Wordpress doesn’t actually have custom user avatars out of the box. You need to use a Wordpress avatar plugin. This is partly why the WP Discourse plugin doesn’t just have a setting to sync Discourse avatars when Discourse is the DiscourseConnect provider, as the way custom avatars are handled will depend on the way a Wordpress implements that kind of custom feature.

However, the WP Discourse plugin gives you a filter you can use to access the Discourse avatar url: wpdc_sso_client_updated_user. This filter will be applied every time the user logs in to Wordpress using DiscourseConnect.

add_filter( 'wpdc_sso_client_updated_user', 'my_wpdc_sso_client_updated_user', 10, 2 );
function my_wpdc_sso_client_updated_user( $updated_user, $query ) {
	## use $query['avatar_url']
}

So, if you use a Wordpress avatar plugin to allow users to set custom avatars in Worpress and this filter you can set Wordpress user’s avatars as their Discourse avatar when Discourse is the DiscourseConnect Provider.

2 Likes

Thanks, that’s exactly Discourse Connect provider for Wordpress. I’ve seen this plugin:

But this plugin also give permission to change avatar for users
In fact, I do not want users to change their avatar. Could I force users use discourse avatar without change avatar permission?

1 Like

Yes, you could use that plugin. You’ll need to use the the filter I mentioned to set the avatar image using the discourse image_url. That will be specific to the Simple Local Avatars plugin and is not something that will be included directly in the WP Discourse plugin.

If you’re unsure about how to handle that integration, you could either reach out to the developers of the plugin, or hire someone in the #marketplace.

1 Like

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