1

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!

1 Answer 1

0

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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