The best way would be to create a new role, and not give it the create topic capability
see
https://codex.bbpress.org/custom-capabilities/
and give it :
// Topic caps
‘publish_topics’ => false,
‘edit_topics’ => false,
‘edit_others_topics’ => false,
‘delete_topics’ => false,
‘delete_others_topics’ => false,
‘read_private_topics’ => true,
Hi,
If you want to use the same permissions/capabilities on all your forums, then a new custom role with the above capabilities is the best way to go.
If you want to ‘protect’ only some of your (sub)forums against new topic creation, then you can use my bbP Toolkit plugin (https://wordpress.org/plugins/bbp-toolkit/).
Pascal.
Hello
Thanks. Just to confirm with you, suppose the role tutor is a role that can not create topics but can edit the reply s/he creates. Accordingly, is the code below be correct?
//code to add tutor role
function add_new_roles( $bbp_roles )
{
/* Add a role called tutor */
$bbp_roles['bbp_tutor'] = array(
'name' => 'Tutor',
'capabilities' => custom_capabilities( 'bbp_tutor' )
);
return $bbp_roles;
}
add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );
function add_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == 'bbp_tutor' )
$caps = custom_capabilities( $role );
return $caps;
}
add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
function custom_capabilities( $role )
{
switch ( $role )
{
/* Capabilities for 'tutor' role */
case 'bbp_tutor':
return array(
// Primary caps
'spectate' => true,
'participate' => true,
'moderate' => false,
'throttle' => false,
'view_trash' => false,
// Forum caps
'publish_forums' => false,
'edit_forums' => false,
'edit_others_forums' => false,
'delete_forums' => false,
'delete_others_forums' => false,
'read_private_forums' => true,
'read_hidden_forums' => false,
// Topic caps
'publish_topics' => false,
'edit_topics' => true,
'edit_others_topics' => false,
'delete_topics' => false,
'delete_others_topics' => false,
'read_private_topics' => true,
// Reply caps
'publish_replies' => true,
'edit_replies' => true,
'edit_others_replies' => false,
'delete_replies' => false,
'delete_others_replies' => false,
'read_private_replies' => true,
// Topic tag caps
'manage_topic_tags' => false,
'edit_topic_tags' => false,
'delete_topic_tags' => false,
'assign_topic_tags' => true,
);
break;
default :
return $role;
}
}
Thanks