Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: User Roles


Anonymous User 96400
Inactive

@anonymized-96400

These functions should sort you out, garynagel:

function sv_check_current_users_blog( $active_signup )
{
if( ! is_user_logged_in() )
return $active_signup;

if( current_user_can( 'YOUR_CAPABILITY' ) )
return $active_signup;
else
return 'none';
}
add_filter( 'wpmu_active_signup', 'sv_check_current_users_blog' );

function sv_remove_create_blog()
{
if( ! current_user_can( 'YOUR_CAPABILITY' ) )
bp_core_remove_subnav_item( 'blogs', 'create-a-blog' );
}
add_action( 'wp', 'sv_remove_create_blog' );

You need to place these functions in your themes functions.php and replace YOUR_CAPABILITY with whatever capability you want to check for. You also need to have blog creation enabled. I’m using a slightly modified version of this to restrict users to maximum 1 blog, so I didn’t test this code at all.

The first function uses a filter to set the variable $active_signup to ‘none’ if the current user does not have a certain capability and for that user blog creation will be disabled. If the user has that capability the variable is not changed.

The second function removes the blog creation tab from the submenu. You probably need to modify the registration page as well.

Hope this helps.

Skip to toolbar