Registered Users Option (Roles)

In Multisite Privacy, there is an option to only allow registered users. Is it possible to restrict registered users to specific roles? We'd like to omit Subscribers.

  • PC
    • WPMU DEV Initiate

    Hiya,

    Greetings and thanks for writing back.

    Sorry but I could not understand what you are trying to achieve here.

    Is it possible to restrict registered users to specific roles? We'd like to omit Subscribers.

    Are you looking to stop subscribers from accessing the site ?

    If yes, them you can simply stop subscriber registrations and do not allow them to register at all.

    However, if you just want to restrict subscriber role (which is already much restricted) you can user a Role Editor plugin.

    Please advise.

    Cheers, PC

  • wcg@uci
    • Site Builder, Child of Zeus

    Hi, yes, I do want to restrict the Subscriber role from viewing the content on Private or "registered users" only sites, but not on other sites. I'm not sure if a role editor plugin will work for that, but I'll take a look.

  • wcg@uci
    • Site Builder, Child of Zeus

    I found a solution. The plugin looks for role capability. For "private" sites (case -2), this is set to "read". By changing this to "edit_posts" or "delete_posts", I can lock out Subscribers from accessing the site, but allow any higher role. Not ideal, but it will work.

    function additional_privacy_can_access_blog($blog_id) {
        $privacy = get_blog_option($blog_id, 'blog_public');
        switch( $privacy ) {
                case '-1':
                    if ( ! is_user_logged_in() ) {
                        return false;
                    }
                    break;
                case '-2':
                    if ( ! is_user_logged_in() ) {
                        return false;
                    } else {
                        if ( ! current_user_can( 'edit_posts' ) ) {
                            return false;
                        }
                    }
                    break;

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.