Skip to:
Content
Pages
Categories
Search
Top
Bottom

Prevent users from creating topics

  • @bttmrc

    Participant

    Hello

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

    It this possible?

Viewing 9 replies - 1 through 9 (of 9 total)
  • @bttmrc

    Participant

    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

    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

    Thank you! It worked

    @robin-w

    Moderator

    great – glad you are fixed

    @bttmrc

    Participant

    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

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

    @bttmrc

    Participant

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

    @krusovice

    Participant

    You are not afraid that this will adversely affect attendance?

    @bttmrc

    Participant

    Well, I wouldn’t even use bbpress on this LMS website. But my client wants it for something really specific and it needs to prevent normal users to create new topics. We will have a fixed topic where they can suggest themes/areas they want to discuss.

    I get its weird but It makes sense for this kinda of project and for what they do.

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