Skip to:
Content
Pages
Categories
Search
Top
Bottom

Prevent users from creating topics


  • bttmrc
    Participant

    @bttmrc

    Hello

    I just want to allow moderators to create topics.
    Normal users can only reply to previous existing topics.

    It this possible?

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

  • bttmrc
    Participant

    @bttmrc

    Anyone?
    I tried to remove a few permissions with a user role/permissions plugin, but after I hit save they got added again.


    Robin W
    Moderator

    @robin-w

    untested, and probably from a purist view not the most elegant solution, but this should work

    add_filter( 'bbp_current_user_can_access_create_topic_form' , 'rew_only_mods' , 10 , 1) ;
    
    function rew_only_mods ($retval) {
    	// Users need to earn access
    	$retval = false;
    	//check if admin
    	if ( bbp_is_user_keymaster() ) {
    		$retval = true;
    	}
    		//check if moderator
    	$role = bbp_get_user_role( get_current_user_id());
    	if ($role == 'bbp_moderator') {
    		$retval = true;
    	}
    // Allow access to be filtered
    	return (bool) apply_filters( 'rew_current_user_can_access_create_topic_form', (bool) $retval );
    }
    

    Also allows keymasters, but I presume you want that.

    Put this in your child theme’s function file – or use

    Code Snippets


    bttmrc
    Participant

    @bttmrc

    Thank you! It worked


    Robin W
    Moderator

    @robin-w

    great – glad you are fixed


    bttmrc
    Participant

    @bttmrc

    I suppose is not possible to target forum specific moderators to allow them to create topics?
    I’m using version 2.6 RC7 that allows to add participants as specific forum moderators.

    Would it be possible to check if a participant is moderator of that forum and if yes allow them to create topics?

    It’s a bit complicated in my head xD


    Robin W
    Moderator

    @robin-w

    sorry, I only do live code, so don’t know what rc7 does


    bttmrc
    Participant

    @bttmrc

    Ah ok I get it, thanks just the same Robin. The solution you provided was very helpful.

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