Tagged: bbpress, Restrict topic creation
Hi Joshua,
Thank you for asking.
I did it for one of my sites. I will look into the code and post it today( a little late today )Thank you
BrajeshHi Joshua,
Do you want to restrict the users from creating in all forums and just reply(It is easy) or on specific forum only?My own solution was a bit mixed with template, so not very useful here but there are filters, if it is the first case, It will be super easy to do.
Hi Joshua,
Thank you.
You can put the following code in your theme’s functions.php and it will workfunction buddydev_bbp_restrict_topic_creation( $can ) { $forum_id = 222;//change your forum id if ( ! bbp_is_user_keymaster() && bbp_is_single_forum() && $forum_id == bbp_get_forum_id() ) { $can = false; } return $can; } add_filter( 'bbp_current_user_can_publish_topics', 'buddydev_bbp_restrict_topic_creation' ); function buddydev_restrict_from_posting_topic( $forum_id ) { $restricted_forum_id = 222; if ( ! bbp_is_user_keymaster() && $forum_id == $restricted_forum_id ) { //set error on bbpress and it will not allow creating topic //not the best idea but I personaly don't like the way bbpress does not provide any forum info at other places to hook bbp_add_error( 403, __( 'Not allowed' ) ); } } add_action( 'bbp_new_topic_pre_extras', 'buddydev_restrict_from_posting_topic' );//
The first filter prevents showing the topic creation form on single forum screen. The second action hook checks at the time of publish and restricts. Most of the time, the first one will suffice but that just hides the form, so I used the other hook to make sure the user is never able to post new topic.
Please let me know how it goes.
- This reply was modified 8 years, 10 months ago by Brajesh Singh. Reason: Fixing the bug in code
Hi Joshua,
I have updated the code.
There was a logical issue where I used bpp_is_forum() that does not check for current forum just the post type. Have updated the code now.You are most welcome. Glad, I was able to help 🙂
The topic ‘ [Resolved] BBpress – restrict topic creation’ is closed to new replies.