Change WordPress user roles and capabilities Forums How to or FAQ How do I change the bbp-role to display the name of the role?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #6003
    demonboy
    Participant

    Hi,

    Just installed the pro plugin. I have created new BBPress roles based on Participant. Each role has an ID and a name but in the forum all roles are just displaying as ‘member’. How do I get the forum to display the name I gave it in URE?

    Cheers

    #6006
    Vladimir
    Keymaster

    Hi,

    It may depend from a theme or additional plugins you use. Show screenshot to give me more information.

    Mine test bbPress shows at forum only user name. It shows role at user profile after click on the user name and it’s a role name not ID: “Forum Role: Participant”.

    #6007
    demonboy
    Participant

    Hi Vladimir, thanks for getting back to me. Please see this Inspector page on the ‘member’ field of the forum:

    author role

    #6008
    Vladimir
    Keymaster

    Thanks for the information.
    Does ‘x-bbp’ or ‘x-sidebar’ tell you something? Something related to a theme or plugin, which change bbPress default representation? We should look there in order to find place where it output author role as a Member.
    Is ‘Member’ a primary role of this user?

    #6009
    demonboy
    Participant

    No, ‘member’ isn’t a primary role, and yes the x-bbp is probably coming from my X theme. Thanks for the prompts – let me now go to the code developers and have a chat with them about this. I’ll get back to you when I’ve heard from them.

    Thank you, Vladimir.

    #6010
    demonboy
    Participant

    Actually, one question: is there a general ID of the of those Participant roles I created? I may be able to get the theme developers to swap bbp-author-name with whatever was created by URE, bearing in mind I created six different participant roles.

    #6013
    Vladimir
    Keymaster

    URE creates/edits user roles via WP API or directly in WP database.

    Every role has 2 attributes: id and name in terms of URE’s user interface or in terms of WP API name (id) and display_name (name).
    Look at the wp-includes/class-wp-roles.php:

    
    public function add_role( $role, $display_name, $capabilities = array() ) {
    	if ( empty( $role ) || isset( $this->roles[ $role ] ) ) {
    		return;
    	}
    	$this->roles[ $role ] = array(
    		'name'         => $display_name,
    		'capabilities' => $capabilities,
    	);
    	if ( $this->use_db ) {
    		update_option( $this->role_key, $this->roles );
    	}
    	$this->role_objects[ $role ] = new WP_Role( $role, $capabilities );
    	$this->role_names[ $role ]   = $display_name;
    	return $this->role_objects[ $role ];
    }
    

    WP_User object which you can get from wp_get_current_user() contains roles property, which contains the list (array) of roles (ID) granted to user.

    #6056
    demonboy
    Participant

    I sussed this out, Vladimir. I added the standard bbpress participant user role to my functions file with the same name as the custom user role created in URE. Now bbpress picks up the correct user role. Thanks for your help!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.