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? Reply To: How do I change the bbp-role to display the name of the role?

#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.