Hello MillaN,
I am thinking about taking advantage of your generous sale offer and getting a lifetime toolbox and prefix.
I was wondering if toolbox has a feature that allows you to restrict posting rights based on usergroup?
Currently I’m using this function to restrict users from posting unless they are keymaster/admin. It works because of the array, but it would be nice to be able to do this on a forum to forum bases inside of the admin area of bbpress.
function buddydev_is_restricted_forum( $forum_id ) { $restricted_forum_ids = array( 292 ); //change it with your forum ids if ( in_array( $forum_id, $restricted_forum_ids ) ) { return true; } return false; } /** * Restrict capability to create new topic * * @param $can * * @return bool */ function buddydev_bbp_restrict_topic_creation( $can ) { //if not key master and current forum is restricted if ( ! bbp_is_user_keymaster() && bbp_is_single_forum() && buddydev_is_restricted_forum( bbp_get_forum_id() ) ) { $can = false; } return $can; } add_filter( 'bbp_current_user_can_publish_topics', 'buddydev_bbp_restrict_topic_creation' ); /** * Restrict post request for new topic * @param $forum_id */ function buddydev_restrict_from_posting_topic( $forum_id ) { if ( ! bbp_is_user_keymaster() && buddydev_is_restricted_forum( $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' ) ); } }
- You must be logged in to reply to this topic.