"Discourse Username" in WP - what does it do?


#1

What is the purpose of the “Discourse Username” field which is editable in the user’s profile in WP?

I sign up as a test user in WP and all is well - user is automatically created in Discourse with the same user name as in WP. Discourse Username in WP is blank at this point. Then I changed the Discourse Username in WP, logged out and logged in again - no changes.

This is all fine, but will probably confuse some users, so is it OK to hide that field in WP from the user? And, what is the best way to hide it?

Thanks.


(Steven Greco) #2

If you allow users to publish posts from WP into Discourse this will assign the post in Discourse to the user specified in that field. Otherwise it will use the default from the plugin settings. You have to enter this field manually. If you are using sso this should match the wp username.


#3

Thanks, @Grex315. Only an admin can publish posts in my setup, so I will ignore it for regular users.

Is there a better way to hide if than via CSS?


(Simon Cossar) #4

Yes, you can add something like this to your theme’s functions.php file:

add_filter( 'user_contactmethods', 'my_namespace_remove_discourse_user' );
function my_namespace_remove_discourse_user( $contact_methods ) {
    unset( $contact_methods['discourse_username'] );

    return $contact_methods;
}

#5

Excellent! Thanks very much @Simon_Cossar.