redwolf83 (@redwolf83)

Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

  • redwolf83
    Participant

    @redwolf83

    Ok, Thanks Robin, I’ve solved the matter.

    at the beginning of form-topic.php I’ve added this code

    <?php 
    $forumid = bbp_get_forum_id();
    if ($forumid == YourForumID(in numbers without quote.)  ) {
    	$displayed_user = bbp_get_user_id( 0, false, true ); 
    	$role = bbp_get_user_role($displayed_user);
    	if ( $role == "bbp_participant" ) {
                   echo '<div class="bbp-template-notice">This forum is marked as closed to new topics from participant, however your can reply to existing topics</div>';
                   return; } 
    }
     ?>

    Thanks for your help, 🙂 ::cheers::
    Have a Nice day!


    redwolf83
    Participant

    @redwolf83

    Ok, Thanks. I have already thought an alternate solution. If forum == “forum” → If user_role == participant → sweep away the topic composer from the forum. I’ve hide the dashboard and admin bar for participant, so this could be a solution I think. May you help me to make something like this?


    redwolf83
    Participant

    @redwolf83

    Thanks, that is very helpful, but it change roles globally. I need it for a specific forum.

    • is possible call these actions to an existing role?
    • and is possible call them only for a specific forum

    I tried this but seems not work…. :/

    // BBPRESS ROLES CONFIG FOR SPECIFIC FORUM
    
    if ( bbp_forum_title(); == "My Forum Title" ) {
    
    	function add_role_caps_filter( $caps, $role )
    	{
        	/* Only filter for roles we are interested in! */
        	if( $role == 'participant' )
            	$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 'participant':
               	 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'   => false,
                    	'read_hidden_forums'    => false,
     
                    	// Topic caps
                    	'publish_topics'        => false,
                    	'edit_topics'           => false,
                    	'edit_others_topics'    => false,
                    	'delete_topics'         => false,
                    	'delete_others_topics'  => false,
                    	'read_private_topics'   => false,
     
    	                // Reply caps
    	                'publish_replies'       => true,
                    	'edit_replies'          => true,
                    	'edit_others_replies'   => false,
                    	'delete_replies'        => true,
                    	'delete_others_replies' => false,
                    	'read_private_replies'  => false,
     
                    	// Topic tag caps
                    	'manage_topic_tags'     => false,
                    	'edit_topic_tags'       => false,
                    	'delete_topic_tags'     => false,
                    	'assign_topic_tags'     => false,
               	 );
     
                	break;
     
            	default :
               	return $role;
        		}
    	}
    }
Viewing 3 replies - 1 through 3 (of 3 total)