# How to link wordpress avatars with discourse?

**URL:** https://meta.discourse.org/t/how-to-link-wordpress-avatars-with-discourse/77255
**Category:** WordPress
**Created:** [January 4, 2018, 4:46pm UTC](https://meta.discourse.org/t/how-to-link-wordpress-avatars-with-discourse/77255 "2018-01-04T16:46:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ryan\_Collins1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryan_collins1/32/76781_2.png) [@Ryan\_Collins1](https://meta.discourse.org/u/Ryan_Collins1)
#### Post date: [January 4, 2018, 4:46pm UTC](https://meta.discourse.org/t/how-to-link-wordpress-avatars-with-discourse/77255/1 "2018-01-04T16:46:22Z")

</div>

Hi folks,

I have a wordpress site connected to my discourse forum via SSO.

The users on my wordpress site upload avatars using the Profile Builder Pro plugin, and these avatars appear throughout my website. However these avatars do not appear on my discourse forum, even though I have checkmarked the “sso overrides avatar” option.

I think the issue might have something to do with the " external system avatars url" but I am not sure. Right now that url reads /letter\_avatar\_proxy/v2/letter/{first\_letter}/{color}/{size}.png

Do I need to replace that url with a url for my wordpress avatar database? If yes, any idea what that might look like or where I can find that url?

Thanks so much for any insight and advice.

Best,

Ryan

---

<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: [January 4, 2018, 4:53pm UTC](https://meta.discourse.org/t/how-to-link-wordpress-avatars-with-discourse/77255/2 "2018-01-04T16:53:57Z")

</div>

It can be done. You might find the information you need in this post and the posts below it: [SSO Avatar Not Updating - #17 by simon](https://meta.discourse.org/t/sso-avatar-not-updating/25569/17).

---

<div class="post-metadata">

### Author: ![Ryan\_Collins1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryan_collins1/32/76781_2.png) [@Ryan\_Collins1](https://meta.discourse.org/u/Ryan_Collins1)
#### Post date: [January 4, 2018, 5:13pm UTC](https://meta.discourse.org/t/how-to-link-wordpress-avatars-with-discourse/77255/3 "2018-01-04T17:13:17Z")

</div>

Ok great, I will give that a try.

Thanks Simon.

---

<div class="post-metadata">

### Author: ![Ryan\_Collins1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryan_collins1/32/76781_2.png) [@Ryan\_Collins1](https://meta.discourse.org/u/Ryan_Collins1)
#### Post date: [January 4, 2018, 5:43pm UTC](https://meta.discourse.org/t/how-to-link-wordpress-avatars-with-discourse/77255/4 "2018-01-04T17:43:48Z")

</div>

@simon thanks again for the help.

Where should I put this filter in my discourse forum? Is there a specific place within my discourse admin settings where I should copy/paste this code?

```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_1', true ) ) {
        $avatar_url = get_user_meta( $user_id, 'custom_field_1', true );
    }

    return $avatar_url;
}

```

---

<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: [January 4, 2018, 5:48pm UTC](https://meta.discourse.org/t/how-to-link-wordpress-avatars-with-discourse/77255/5 "2018-01-04T17:48:50Z")

</div>

> [@Ryan\_Collins1](#):
>
> Where should I put this filter in my discourse forum?

That code needs to be added to your WordPress code, not to Discourse. The easiest place to add it is to your theme’s `functions.php` file. There is some risk in editing your `functions.php` file on a live site. Before you do it you should be sure that you can access you have some way of accessing your theme’s files in case you make a mistake.

---

<div class="post-metadata">

### Author: ![Ryan\_Collins1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryan_collins1/32/76781_2.png) [@Ryan\_Collins1](https://meta.discourse.org/u/Ryan_Collins1)
#### Post date: [January 4, 2018, 5:57pm UTC](https://meta.discourse.org/t/how-to-link-wordpress-avatars-with-discourse/77255/6 "2018-01-04T17:57:58Z")

</div>

Ok, sounds good.

I will test it out on a copy of my live site first.

Much appreciated!
