Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do i customize user roles?


  • esportsstream
    Participant

    @esportsstream

    I am using bbpress ver 2.5.4

    This is my problem. Spectator can not post (want to change this) spectator can not see private forums (which I want to keep the same)

    Contributor can post (I do want) Can see private forums (dont want)

    This is what i want to do. I want to either make it so a spectator can post and not see private forums or I want to set it up a new default subscriber role that can post in normal forum sections but can not see or post in private sections until I turn them into contributor.

    How do I do this? I am using bbpress as a plugin for my wordpress site not on wordpress.org

    Thanks

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

  • esportsstream
    Participant

    @esportsstream

    From what i can gather all i have to do is change the permissions in thefuntions.php file.
    Can someone tell me where this is located?


    esportsstream
    Participant

    @esportsstream

    uhh ok I found the funtions.php file but i have no idea how to change it to spectators can post. Can someone please help


    esportsstream
    Participant

    @esportsstream

    So i made a new file called bbpress-functions.php and put this into it

    <?php
    //code to add tutor role 
    
    function add_apply_role( $bbp_roles )
    {
    	/* Add a role called apply */
    	$bbp_roles['bbp_apply'] = array(
    		'name' => 'apply',
    		'capabilities' => custom_capabilities( 'bbp_apply' )
    		);
    	return $bbp_roles;
    }
     
    add_filter( 'bbp_get_dynamic_roles', 'add_apply_role', 1 );
    
    function apply_role_caps_filter( $caps, $role )
    {
    	/* Only filter for roles we are interested in! */
    	if( $role == 'bbp_apply' )
    		$caps = custom_capabilities( $role );
     
    	return $caps;
    }
     
    add_filter( 'bbp_get_caps_for_role', 'apply_role_caps_filter', 10, 2 );
    
    function custom_capabilities( $role )
    {
    	switch ( $role )
    	{
    		 
    		/* Capabilities for 'apply' role */
    		case 'bbp_apply':
    			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'        => true,
    				'edit_topics'           => true,
    				'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'        => false,
    				'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'     => true,
    			);
    			break;
     
    		default :
    			return $role;
    	}
    }
    

    I have no idea where i put this file in my site directory……


    esportsstream
    Participant

    @esportsstream

    I use bulletpress as my theme. I have tried all sorts of directories and have not gotten anything to work 🙁


    esportsstream
    Participant

    @esportsstream

    Ok do to fix it i had to write that code in the actual funtions.php file of my main theme


    Robin W
    Moderator

    @robin-w

    Great – presume you’re fixed if not

    Layout and functionality – Examples you can use

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