# Don't update avatar if default

**URL:** https://meta.discourse.org/t/dont-update-avatar-if-default/118877
**Category:** WordPress
**Created:** [28 mei 2019 om 14:22 UTC](https://meta.discourse.org/t/dont-update-avatar-if-default/118877 "2019-05-28T14:22:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [28 mei 2019 om 14:22 UTC](https://meta.discourse.org/t/dont-update-avatar-if-default/118877/1 "2019-05-28T14:22:08Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [28 mei 2019 om 16:35 UTC](https://meta.discourse.org/t/dont-update-avatar-if-default/118877/2 "2019-05-28T16:35:08Z")

</div>

> [@dylanb](#):
>
> it automatically changes users avatars to the default avatar on my site (basically the site logo),

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.

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [28 mei 2019 om 17:42 UTC](https://meta.discourse.org/t/dont-update-avatar-if-default/118877/3 "2019-05-28T17:42:42Z")

</div>

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?

> **[Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User...](https://wordpress.org/plugins/wp-user-avatar/)**
>
> Setup paid membership, accept payment, sell subscription & digital product, paywall, create login & registration form, user profile & member directory

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [28 mei 2019 om 18:08 UTC](https://meta.discourse.org/t/dont-update-avatar-if-default/118877/4 "2019-05-28T18:08:34Z")

</div>

> [@dylanb](#):
>
> Yep, I am using WP User Avatar which sets a default avatar.

That will be the problem. The [WP Discourse](https://github.com/discourse/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:

```php
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;
}

```

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [28 mei 2019 om 18:23 UTC](https://meta.discourse.org/t/dont-update-avatar-if-default/118877/5 "2019-05-28T18:23:41Z")

</div>

That worked perfectly, thanks.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [27 juni 2019 om 18:23 UTC](https://meta.discourse.org/t/dont-update-avatar-if-default/118877/6 "2019-06-27T18:23:41Z")

</div>

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