I want to disable temporarily site visiting and user logins to a multisite blog for the site maintenance time, excepting for super-admins and for a specific user. I found this function (thanks @joshc) and it works very well, but I don't know how to add the specific username to it so it can visit the site too. Please help!

This is what I tried, but without success, the user test_user is not allowed to login:

function site_maintenance() {
    global $user_login;
    if ( !is_super_admin() || $user_login != 'test_user' ) {
        $logout_url = wp_login_url().'?mode=maintainance';
        wp_redirect( $logout_url, 302 );
add_action('get_header', 'site_maintenance');

1 Answer 1


Your if case matches any user who is not both a super admin and test_user.

For example, given a user test_user who is not superadmin, the result would be

if (true || false) redirect

Since one condition is true, the redirect would be triggered. Using the && operator, you'd get

if (true && false) redirect.

Since both are not true, it doesn't trigger the redirect.

  • But && will mean that test_user must be a super admin, or not? Anyway, I will try what you suggest, thank you!
    – Yuri
    Nov 7, 2014 at 17:45
  • Thank you, Jeremiah! With your help my function now works as expected!
    – Yuri
    Nov 8, 2014 at 7:57

Your Answer

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

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