Bringing over name from WordPress

Is it possible to bring over the first and last name from WordPress to the ‘Name’ field in Discourse when a user’s account is automatically created? Right now it appears to bring over the user’s email address into the name field, which doesn’t make sense. In our signup process on WordPress the user is required to enter a name, so we’d rather them not have to re-enter it in Discourse, if possible. I searched through the options/settings in the WordPress + Discourse plugin, but didn’t see anything.


What it should be doing now is bringing the user’s display_name into the name field. If the user’s display name is their email address then that’s what you’ll be getting. I can change the plugin so that it checks to see if either or both the first and last name are set for a user, and if so, use that to fill in the name field.

Edit: the display_name is editable on a user’s WordPress profile page, and Discourse doesn’t require users to supply a full name, so we probably shouldn’t send the full name by default. It can easily be added as an option though.


I also require full names in WP through Paid Memberships Pro, so having that pushed through to Discourse would be great!

@simon, that makes sense. It appears our membership setup (MemberPress) sets the email address as the default display name. I could probably write a function or find a plugin to force the display name in WordPress to be the first and last name, but if there was an option in the plugin to check first and last name in WordPress and set that, I think that would be helpful. In situations where a first and last name are set in WordPress, I can’t think of a situation where you wouldn’t want those to carry over to Discourse.

The issue I see is that WordPress has fields for entering your first and last name, but also gives the option of setting your display name to something different (username, first only, last only.) Someone could enter their first and last name in their profile without expecting it to be displayed publicly.

Adding a ‘Use Real Name for Discourse Name Field’ option to the plugin’s SSO Provider settings would be easy to do. Unless there are any objections to doing that, I can add it to the next update.


@simon, yes, that makes sense. Adding that field would be awesome. Any idea when the next update will be? No rush, but just trying to figure out if we should take the time to put a stop-gap measure in place or wait for the plugin to update. Thanks!

I’ll try to make a small update this coming Sunday. If you’d like to override the Discourse names of user’s who have already had their name set to their email address, you’ll need to select the ‘sso overrides name’ setting on Discourse. (Found at Unless that setting is enabled, the Discourse name is only set on the initial SSO request.

1 Like

@simon That would be great and thanks for the heads up on setting that option.

@simon We are continuing to work through this internally with our team. I think we may sync name, email, bio/description and avatar from WordPress to have a single account page for users to edit. If we do this though, the fields on the account preferences page (/u/_____/preferences/account) are all un-editable (which is what we want). Is there a way to add a message to the top of this page that would allow us to let users know they should go to the WordPress account page to update the information? We are just afraid the dual account setup will confuse users and are trying to minimize the confusion as much as possible.

1 Like

Probably the easiest way to do it is through a site customization at /admin/customize/themes/2/common/head_tag/edit.

Put whatever html you want to use between the script tags.
If you have multiple themes enabled on your site, you’ll need to add this to the head section of each one.

<script type='text/x-handlebars' data-template-name='/connectors/user-profile-primary/add-sso-info'>
    <div class="sso-profile-info">
        You can set your username, email address etc...<a href="">here</a>
1 Like

Yep, that would work. Thanks!

This is now available as an option in the plugin’s SSO Provider settings.

Awesome. I just updated. Thank you!

@simon On the avatar functionality, it appears to pull from avatar_url. That function can’t be overwritten to my understanding and will always use the Gravtar URL. We are allowing users to update their avatar image within our MemberPress account. The URL looks like get_user_meta($user->ID, ‘mepr_custom_avatar’, true);. What’s the best way to make this work within the plugin? I guess I’d have to hard-code the change into the plugin? Any better option?

There’s some information about how to do in this post, and the posts that follow it: SSO Avatar Not Updating

Assuming that get_user_meta($user->ID, 'mepr_custom_avatar', true) returns the absolute URL to the avatar, this should work.

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

    return $avatar_url;

If it’s not returning the absolute URL (starting with http(s):// you’ll need to append that to the URL so that Discourse can access it.

@simon Hmm. that doesn’t seem to be working. I checked out the topic you shared and tried the other option as well. Let me make sure I am doing everything right:

  • I have the force avatar setting checked in the plugin settings
  • I added the above code to my functions.php file
  • I logged out of Discourse and then logged back in (via WordPress)

Anything I am missing? Any other ideas why it wouldn’t be working? The function does return the full URL of the image (

It sounds like you’re doing it correctly. You could try selecting the ‘sso overrides avatar’ setting on Discourse, Also, try refreshing your browser after logging in with the new avatar.

@simon Okay, it is working now. I think the issue is that when I logged out of WordPress it wasn’t actually logging me out of Discourse…so when I was logging back into WordPress, it wasn’t really logging back into Discourse because I was already logged in. Make sense? Any way to make Discourse force logout when you logout of WordPress?

1 Like

Yes, it should happen automatically. It’s another conflict with the MemberPress plugin. See if you can disable the ‘logout redirect’ in the MemberPress settings.

@simon There is an option ‘URL to direct member to after logout.’ If you leave this blank it goes to the default /wp-login.php?loggedout=true. Even with this being the case it appears to keep me logged in to the forum though.