Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Adding roles

@zirow

Participant

I’ve added this reply like 3times and everytime i edit it it disappeared and when i try to re-paste it and submit i cant cuz i get a warning for duplication 😛

I’m pretty sure theirs a better way of doing it but that’s how I did since its the only way I could figure it out

Open Capabilities.php

Under “function bbp_get_caps_for_role”
Add this case along with the other cases

case bbp_get_tutor_role() :
$caps = array(

// Primary caps
‘spectate’ => true,
‘participate’ => true,

// Forum caps
‘read_private_forums’ => true,

// Topic caps
‘publish_topics’ => true,
‘edit_topics’ => true,

// Reply caps
‘publish_replies’ => true,
‘edit_replies’ => true,

// Topic tag caps
‘assign_topic_tags’ => true,
);

Under:

function bbp_get_participant_role() {

// Filter & return
return apply_filters( ‘bbp_get_participant_role’, ‘bbp_participant’ );
}

Add:

function bbp_get_tutor_role() {

// Filter & return
return apply_filters( ‘bbp_get_tutor_role’, ‘bbp_tutor’ );
}

Save and close Capabilities.php and open bbpress.php in the plugin directory not the one inside the theme.

Search for:
public function roles_init() {

You will see this code:

$keymaster = bbp_get_keymaster_role();
$moderator = bbp_get_moderator_role();
$participant = bbp_get_participant_role();
$spectator = bbp_get_spectator_role();
$blocked = bbp_get_blocked_role();

// Build the roles into one useful array
$this->roles[ $keymaster ] = new WP_Role( ‘Keymaster’, bbp_get_caps_for_role( $keymaster ) );

$this->roles[ $moderator ] = new WP_Role( ‘Moderator’, bbp_get_caps_for_role( $moderator ) );
$this->roles[ $participant ] = new WP_Role( ‘Participant’, bbp_get_caps_for_role( $participant ) );
$this->roles[ $spectator ] = new WP_Role( ‘Spectator’, bbp_get_caps_for_role( $spectator ) );
$this->roles[ $blocked ] = new WP_Role( ‘Blocked’, bbp_get_caps_for_role( $blocked ) );
}

So you just want to add these two codes in their:

$tutor = bbp_get_tutor_role();

$this->roles[ $tutor ] = new WP_Role( ‘tutor’, bbp_get_caps_for_role( $tutor ) );

If u want to rename an existing role u added or bbpress default roles u can add this into your functions.php

Add:

function ntwb_bbpress_custom_role_names() {

return array(

// Keymaster

bbp_get_keymaster_role() => array(

‘name’ => ‘Administrator’,

‘capabilities’ => bbp_get_caps_for_role( bbp_get_keymaster_role() )

),

// Moderator

bbp_get_moderator_role() => array(

‘name’ => ‘Moderator’,

‘capabilities’ => bbp_get_caps_for_role( bbp_get_moderator_role() )

),

// Participant

bbp_get_participant_role() => array(

‘name’ => ‘Member’,

‘capabilities’ => bbp_get_caps_for_role( bbp_get_participant_role() )

),

bbp_get_tutor_role() => array(

‘name’ => ‘Member2’,

‘capabilities’ => bbp_get_caps_for_role( bbp_get_tutor_role() )

),

// Spectator

bbp_get_spectator_role() => array(

‘name’ => ‘Spectator’,

‘capabilities’ => bbp_get_caps_for_role( bbp_get_spectator_role() )

),

// Blocked

bbp_get_blocked_role() => array(

‘name’ => ‘Blocked’,

‘capabilities’ => bbp_get_caps_for_role( bbp_get_blocked_role() )

)

);

}

Skip to toolbar