Skip to:

Display user_role not bbp-author-role

  • demonboy



    I attempted to create some new bbp roles using the code in the codex to copy the ‘participant’ role. Unfortunately this did not work for me despite deactivating all plugins (seems quite a few other people had the same issue).

    Instead I am using User Role Editor to create a new forum role, which I have called ‘bosun’. Upon sign-up a new user is correctly assigned this role and has the capabilities of a participant, which is great, but their forum role is still displaying as ‘spectator’.

    I would like to display the user’s role under the avatar.

    One thing I can do is display:none the div class bbp-author-role and then add in a new div to display the user_role, which I think is what URE plugin generates.

    I appreciate that some of this has to do with the URE plugin and that it is not supported here. What I am trying to understand is what I need to change in order to hide the bbp-author-role div and add in a new div calling the URE role. I can only find references to bbp-author-role in templates.php which is a function:

    function bbp_topic_author_role( $args = array() ) {
    	echo bbp_get_topic_author_role( $args );
    	 * Return the topic author role
    	 * @since bbPress (r3860)
    	 * @param array $args Optional.
    	 * @uses bbp_get_topic_id() To get the topic id
    	 * @uses bbp_get_user_display_role() To get the user display role
    	 * @uses bbp_get_topic_author_id() To get the topic author id
    	 * @uses apply_filters() Calls bbp_get_topic_author_role with the author
    	 *                        role & args
    	 * @return string topic author role
    	function bbp_get_topic_author_role( $args = array() ) {
    		// Parse arguments against default values
    		$r = bbp_parse_args( $args, array(
    			'topic_id' => 0,
    			'class'    => 'bbp-author-role',
    			'before'   => '',
    			'after'    => ''
    		), 'get_topic_author_role' );
    		$topic_id    = bbp_get_topic_id( $r['topic_id'] );
    		$role        = bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) );
    		$author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], $r['class'], $role, $r['after'] );
    		return apply_filters( 'bbp_get_topic_author_role', $author_role, $r );
Viewing 2 replies - 1 through 2 (of 2 total)

  • demonboy


    OK, I think I have solved this by following this thread, except I had to do one thing the other way around…

    1. Scrap User Role Editor and install the Members plugin by Justin Tadlock
    2. Don’t put anything in your functions file
    3. In WordPress under Users/Roles, clone the Participant user role and give it a name and slug (in my case I am using ‘bosun’) and save the new role.
    4. Add this code to your functions file:

    function vip_add_custom_role( $bbp_roles ) {
    $bbp_roles['bosun'] = array(
    'name' => 'Bosun',
    'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
    return $bbp_roles;
    add_filter( 'bbp_get_dynamic_roles', 'vip_add_custom_role', 1 );

    … where bbp_roles and name is changed to your own name of the user role. This must be the same as the name/slug you inserted when cloning the participant user role.

    5. Now any forum user assigned this user role will display the correct role, rather that ‘participant’ ‘subscriber’ or ‘spectator’.

    The thing I had to do the other way around from the instructions in the other thread was to not put anything in the functions file and install the plugin first.

    Phew. Took me two days to get there!



    Scrap that. Doesn’t work. This is driving me nuts…

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar