Prevent participant from creating topic but allow replies
-
In a bbPress forum I want to prevent participants from creating topics but allow replies. In searching the Internet I found code examples from which I selected some to build a plugin. I know a little PHP but WordPress is like a “black box.”
add_action(‘wp_loaded’,’modify_participant’);
function ‘modify_participant'()
{
add_filter(‘mod_participant’, ‘upd_participant’);
}function upd_participant($role,$caps)
{
$role = bbp_get_participant_role();
$caps = modify_capabilities($role);
}function modify_capabilities($role)
{
return array(// Topic caps
‘publish_topics’ => false,
‘edit_topics’ => false,
‘edit_others_topics’ => false,
‘delete_topics’ => false,
‘delete_others_topics’ => false,
‘read_private_topics’ => false,// Topic tag caps
‘manage_topic_tags’ => false,
‘edit_topic_tags’ => false,
‘delete_topic_tags’ => false,
‘assign_topic_tags’ => false
)
}For instance the WP loaded hook causes it to run once at the start which should call those functions to initialize things. Is an add_filter also executed at that time to complete initialization? Then the black box proceeds with the bbp_get_parcipant_role routine so that the capabilities array elements can be updated. I read that WP filters always expect an object to be returned. It seems that these wouldn’t be permanent but just temporary in memory for executing that page. However my suspicion is that more coding would be necessary because that would be too much to depend on the black box for.
- You must be logged in to reply to this topic.