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'm trying to make some modifications to a wordpress multisite and i could use some help from someone more experienced. I want to restrict the acces to my blogs unless the user has an account. In detail : i have a series of blogs, each one with an admin/autor. If a user wants to read posts from a blog, he should first go on the main site, to wp-signup.php and create an account. I'm planning on creating a plugin, active on all subsites. Is this possible? if yes, could someone give me some directions - wich hooks, filters and functions i would need ?

Thank you!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Test if the current visitor is logged in and registered as user

// If the user's not registered & logged in, abort
if ( ! is_user_logged_in() )
    return;

Test if the currently logged in user has a capability for the specific blog

$blog_id = ''; // You need to retrieve and set that here
// If the currently logged in user hasn't got the 'manage_options' cap - which is assigned to admins and above - abort
if ( ! current_user_can_for_blog( $blog_id, 'manage_options' ) )
    return;

If it's not necessary to check for a specific blog, we can test just the capability.

// If the currently logged in user hasn't got the 'manage_options' cap - which is assigned to admins and above - abort
if ( ! current_user_can( 'manage_options' ) )
    return;

This (old and not maintained) plugin gives you better in-depth look at what users deliver.

share|improve this answer
    
thank you! i'll try it –  maephisto Jul 5 '11 at 6:32

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.