# SSO Avatar Not Updating

**URL:** <https://meta.discourse.org/t/sso-avatar-not-updating/25569>\
**Category:** WordPress\
**Created:** [2015年二月23日 15:05 UTC](https://meta.discourse.org/t/sso-avatar-not-updating/25569 "2015-02-23T15:05:54Z")\
**Posts on this page:** 1\
**Showing post:** 17

<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:** [2017年六月4日 02:58 UTC](https://meta.discourse.org/t/sso-avatar-not-updating/25569/17 "2017-06-04T02:58:08Z")

</div>

There’s a filter in the wp-discourse plugin that you can use to change the avatar that’s sent to Discourse. From looking at the wordpress-profile-builder docs, it looks like they save the custom avatar as user metadata. From the example on this page, they are saving the avatar URL under the key ‘custom\_field\_57’: [Avatar Upload Field](https://www.cozmoslabs.com/docs/profile-builder-2/manage-user-fields/avatar-upload-field/)

Assuming that what is saved in that field is the absolute URL of the avatar, something like this will work. I’ve tested this on a live site by saving the string `http://example.com/wp-content/uploads/my-profile-pic.jpg` as user metadata. If it’s not an absolute URL that’s saved in that field, it will take a bit more work to put it together.

```plaintext
add_filter( 'wpdc_sso_avatar_url', 'my_namespace_use_custom_avatar', 10, 2 );
function my_namespace_use_custom_avatar( $avatar_url, $user_id ) {
    if ( get_user_meta( $user_id, 'custom_field_57', true ) ) {
        $avatar_url = get_user_meta( $user_id, 'custom_field_57', true );
    }

    return $avatar_url;
}

```

If you enable verbose sso logging on your forum, you’ll be able to see what values are being sent with the sso payload.

Edit: before trying this, enable the verbose sso logging setting on Discourse and take a look at the Discourse logs to see what URL is currently being sent as the avatar\_url with the SSO payload.

---

_[View the full topic](https://meta.discourse.org/t/sso-avatar-not-updating/25569)._
