Currently, there are 0 users and 1 guest visiting this topic.
Author
Topic
#64982

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' ) );
 
    }
}
Topic Information
Feature Request
7.4
5.5
3.1
Viewing 2 replies - 1 through 2 (of 2 total)
Author
Replies
  • #64986

    GD bbPress Toolbox Pro doesn’t have support for ‘groups’ based restrictions. There are many plugins implementing user groups in their own way, and it is very hard to support that. There is only one bbPress Groups plugin available, but it is outdated and I think no longer developed.

    Many users asked me about making the bbPress users groups plugin, and I do plan to do that, but I can’t say when I will have enough time for something like that.

    Milan

    Dev4Press - Premium plugins for WordPress.

  • #64987

    GD bbPress Toolbox Pro doesn’t have support for ‘groups’ based restrictions. There are many plugins implementing user groups in their own way, and it is very hard to support that. There is only one bbPress Groups plugin available, but it is outdated and I think no longer developed.

    Many users asked me about making the bbPress users groups plugin, and I do plan to do that, but I can’t say when I will have enough time for something like that.

    Milan

    Ah I understand. I use the AAM plugin for custom groups. The code above lets me restrict “post new topic” permissions for all but keymasters. For me it isn’t such a big deal since I only restrict my “Announcements” forum. But it might come in handy for those who want to restrict multiple forums from regular members from opening new topics.

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

If you don't have an account on this website, you can register for a free account here:

Register