# WP Discourse SSO does not synchronize local avatars provided by Advanced Site Enhancements

**URL:** https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809
**Category:** WordPress
**Created:** [4 ביולי,‏ 2026,‏ 3:00am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809 "2026-07-04T03:00:53Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [4 ביולי,‏ 2026,‏ 3:00am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/1 "2026-07-04T03:00:53Z")

</div>

Hello,

I am using:

- WordPress
- [WP Discourse](https://github.com/discourse/wp-discourse) (latest version)
- Advanced Site Enhancements (ASE), using its Local User Avatar feature (no Gravatar)

The avatar is correctly displayed everywhere in WordPress.

ASE stores the attachment ID in the user meta field:

`local_user_avatar_attachment_id`

During WordPress SSO login, however, Discourse always imports the default avatar instead of the local avatar.

I already tried using the `wpdc_sso_avatar_url` filter to return the media library URL, but it made no difference.

Therefore I have two questions:

1. Does [WP Discourse](https://github.com/discourse/wp-discourse) still use `wpdc_sso_avatar_url` for avatar synchronization?
2. Which function or filter is currently responsible for determining the avatar URL sent to Discourse?

Any guidance would be appreciated.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [6 ביולי,‏ 2026,‏ 8:25am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/2 "2026-07-06T08:25:01Z")

</div>

Hey @miednr, yes, `wpdc_sso_avatar_url` is still used for avatar sync. Let’s see if we can get it working for you.

1. Do you have `Force Avatar Update` in the [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) Provider settings enabled?
2. Please share the function you’re using with `wpdc_sso_avatar_url`

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [6 ביולי,‏ 2026,‏ 9:40am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/3 "2026-07-06T09:40:51Z")

</div>

Hello @angus !

Thank you for your attention to this. Yes, I have “Force Avatar Update” enabled.

My function at this point in time is:

```plaintext

<?php
add_filter( 'get_avatar_url', function( $url, $id_or_email, $args ) {
    $user = false;
    if ( is_numeric( $id_or_email ) ) {
        $user = get_user_by( 'id', (int) $id_or_email );
    } elseif ( $id_or_email instanceof WP_User ) {
        $user = $id_or_email;
    }
    if ( ! $user ) {
        return $url;
    }
    $avatar_id = get_user_meta( $user->ID, 'local_user_avatar_attachment_id', true );
    if ( ! $avatar_id ) {
        return $url;
    }
    $local_avatar_url = wp_get_attachment_image_url( (int) $avatar_id, 'full' );
    return $local_avatar_url ?: $url;
}, 10, 3 );

```

I changed it some times, to make it work. But, I guess, I’ve had a better version before. 😉

Would be great, if we could find a working version.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [6 ביולי,‏ 2026,‏ 12:09pm UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/4 "2026-07-06T12:09:28Z")

</div>

Did you perhaps share the wrong snippet? That code is using the `get_avatar_url` filter. As you observed, the filter is `wpdc_sso_avatar_url`.

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [6 ביולי,‏ 2026,‏ 4:53pm UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/5 "2026-07-06T16:53:12Z")

</div>

Hello @angus

I shard a different approach, that I tried. Sorry. This is the best snippet, I can share:

```plaintext
add_filter( 'wpdc_sso_avatar_url', function( $avatar_url, $user_id ) {

$avatar_id = get_user_meta( $user_id, 'local_user_avatar_attachment_id', true );

if ( ! $avatar_id ) {
    return $avatar_url;
}

$local_avatar_url = wp_get_attachment_image_url( (int) $avatar_id, 'full' );

if ( ! $local_avatar_url ) {
    return $avatar_url;
}

return esc_url_raw( $local_avatar_url );

}, 10, 2 );

```

I tried this snippet. ASE stores the local avatar attachment ID in the user meta field `local_user_avatar_attachment_id`. The attachment ID exists and points to a media library image. However, Discourse still imports the default avatar after WordPress login/SSO sync.

I also tried the same approach with the `thumbnail` image size instead of `full`, but the result was the same.

Thank you for having a look!

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [6 ביולי,‏ 2026,‏ 5:15pm UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/6 "2026-07-06T17:15:05Z")

</div>

Hi @angus,

I have received a response from the ASE (Advanced Site Enhancements) developer that may help narrow this down.

According to them:

\* ASE hooks into the standard WordPress avatar APIs:

\* get\_avatar (priority 5)

\* get\_avatar\_url (priority 10)

\* get\_avatar\_data (priority 10)

\* There are currently no known compatibility issues with other plugins.

\* The local avatar is stored in the Media Library, and the attachment ID is saved in the user meta field:

local\_user\_avatar\_attachment\_id

They also suggested manually retrieving the avatar URL like this:

```plaintext
$attachment_id = (int) get_user_meta( $user_id, 'local_user_avatar_attachment_id', true );

if ( $attachment_id ) {

$avatar_url = wp_get_attachment_image_url( $attachment_id, array( 128, 128 ) );

}

```

I also tried using this inside the wpdc\_sso\_avatar\_url filter, but the result was unchanged—the default Discourse avatar is still used after login.

Since ASE claims to hook into get\_avatar\_url(), I was wondering:

\* Does [WP Discourse](https://github.com/discourse/wp-discourse) call get\_avatar\_url() before or after applying the wpdc\_sso\_avatar\_url filter?

\* Is there anything specific about the avatar URL (size, accessibility, timing, etc.) that Discourse expects during avatar synchronization?

I’d be happy to run any additional tests or add temporary debugging if that would help.

Thanks again for your help!

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [6 ביולי,‏ 2026,‏ 5:20pm UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/7 "2026-07-06T17:20:52Z")

</div>

Do you have the `discourse_connect_overrides_avatar` site setting enabled in Discourse?

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [6 ביולי,‏ 2026,‏ 5:39pm UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/8 "2026-07-06T17:39:21Z")

</div>

> [@angus](#):
>
> discourse\_connect\_overrides\_avatar

Yes, it has been activated.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [7 ביולי,‏ 2026,‏ 4:58am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/9 "2026-07-07T04:58:26Z")

</div>

Ok, let’s check what’s in the final SSO params. Please add this filter and check what it logs

```php
add_filter( 'wpdc_sso_params', function ( $params ) {
   error_log( "avatar_url: {$params['avatar_url']} force: {$params['avatar_force_update']}" );
   return $params;
});

```

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [7 ביולי,‏ 2026,‏ 6:52am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/10 "2026-07-07T06:52:02Z")

</div>

The snippet is loaded on every page load, but `wpdc_sso_params` never fires during logout/login or during the Discourse login flow.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [7 ביולי,‏ 2026,‏ 8:14am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/11 "2026-07-07T08:14:15Z")

</div>

If that filter never fires then it is likely that you don’t have [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) setup properly, or you’re not using Wordpress as the provider to login to Discourse. Please share the meta file from [WP Discourse](https://github.com/discourse/wp-discourse) \> Logs.

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [7 ביולי,‏ 2026,‏ 8:25am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/12 "2026-07-07T08:25:54Z")

</div>

Hello @angus

sure, please have a look:

### Server ###

WordPress - 7.0

PHP - 8.3.6

MySQL - 8.4.9

### [WP Discourse](https://github.com/discourse/wp-discourse) Settings (Secrets Excluded) ###

connection-logs - 0

display-subcategories - 1

allow-tags - 1

max-tags - 15

publish-as-unlisted - 0

full-post-content - 0

custom-excerpt-length - 100

add-featured-link - 1

auto-publish - 1

force-publish - 1

force-publish-max-age - 0

publish-failure-notice - 1

auto-track - 1

allowed\_post\_types - post

exclude\_tags -

hide-discourse-name-field - 0

discourse-username-editable - 0

direct-db-publication-flags - 0

verbose-publication-logs - 0

enable-discourse-comments - 1

comment-type - display-public-comments-only

ajax-load - 1

load-comment-css - 1

discourse-new-tab - 1

hide-wordpress-comments - 1

show-existing-comments - 0

max-comments - 10

min-replies - 0

min-score - 0

min-trust-level - 0

bypass-trust-level-score - 0

only-show-moderator-liked - 0

custom-datetime-format -

cache-html - 0

clear-cached-comment-html - 0

verbose-comment-logs - 0

use-discourse-webhook - 1

use-discourse-user-webhook - 1

webhook-match-user-email - 0

verbose-webhook-logs - 0

verbose-sso-logs - 1

enable-sso - 1

auto-create-sso-user - 1

real-name-as-discourse-name - 0

force-avatar-update - 1

redirect-without-login - 0

sso-client-enabled - 0

sso-client-login-form-change - 0

sso-client-sync-by-email - 0

sso-client-disable-create-user - 0

sso-client-sync-logout - 0

logs-enabled - 1

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [7 ביולי,‏ 2026,‏ 8:47am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/13 "2026-07-07T08:47:38Z")

</div>

Wordpress is indeed set up as the provider, but, seemingly, the [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) code isn’t firing. This suggests to me that you’re not actually logging in using [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true), or you’re not loading the snippets or logs correctly. Do you perhaps have some other login method setup, such as OAuth? Perhaps record exactly what you’re doing to test this. Try to capture the urls in the recording and / or by enabling “Preserve Log” in the dev tools network tab.

> but `wpdc_sso_params` never fires during logout/login or during the Discourse login flow

Also, please share how you came to this conclusion.

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [7 ביולי,‏ 2026,‏ 9:33am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/14 "2026-07-07T09:33:24Z")

</div>

I added “error\_log( ‘[WPDC avatar debug] snippet loaded’ );”

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [7 ביולי,‏ 2026,‏ 10:03am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/15 "2026-07-07T10:03:45Z")

</div>

> [@angus](#):
>
> This suggests to me that you’re not actually logging in using [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true), or you’re not loading the snippets or logs correctly.

1. I am using [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) to login, vie the standard WordPress Login.
2. I am using Advanced Site Enhancements (ASE) Snippets Manager to add my snippets. And your debug snippet (modified as desribed) was able to let there be some entries in debug.log

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [7 ביולי,‏ 2026,‏ 10:11am UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/16 "2026-07-07T10:11:15Z")

</div>

Something is not quite right, as it’s not possible to login using [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) without `wpdc_sso_params` firing. You need to figure out what that is. Without direct access to your setup, I can’t figure that part out.

---

<div class="post-metadata">

### Author: ![miednr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miednr/32/539145_2.png) [@miednr](https://meta.discourse.org/u/miednr)
#### Post date: [7 ביולי,‏ 2026,‏ 4:28pm UTC](https://meta.discourse.org/t/wp-discourse-sso-does-not-synchronize-local-avatars-provided-by-advanced-site-enhancements/406809/17 "2026-07-07T16:28:08Z")

</div>

Thank you @angus for your efforts. I will now try my best to find out more about this issue and will let you know my findings.
