Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a series of sites that I maintain as part of a WordPress multisite install. I'd like to be able to create users accounts that are restricted to viewing only a single one of these sites. Is this possible?

Once this is accomplished, is there a way to determine this permission status programmatically? I'd like to be able to get a list of all the sites the current user has access to, or at the very least, test if the user has permission to access a specific site.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Use is_user_member_of_blog() to check if the current user has been assigned to the blog in wp-admin/network/site-users.php. Then hook into template_redirect and run the test:

add_action( 'template_redirect', function() {

    if ( ! is_user_member_of_blog() )   
        die( 'Please ask the network administrator to get access to this blog.' );
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.