I have a blog network (Multisite), with domain mapping plugin installed, and some of my sites are under development, so I want to lock them from not registered users.

I tested a few plugins designed for this purpose (Private Only, Private WP suite, Private WP, Members Only, Registered Users Only, Absolute Privacy and Wp-Private) and all failed.

I accessed site, saw login form, filled it in, marked "Remember Me", logged in and I was redirected to Dashboard (user section) not to site itself. When I re-entered site URL (domain) I again saw login page, though I marked "Remember Me". There is not way I can access site itself.

I even wrote my own, as simple as possible, plugin for this:

function show_guest_notice()
        echo('No way, man!');

add_action('get_header', 'show_guest_notice');

and it also failed.

It seems that either is_user_logged_in() or string user cookie fails on Multisite with Domain Mapping plugin.

I saw this post and answer by amontobin ("(...) was a domain mapping cookie issue. Now working fine"), but it only assured me that using Multisite with Domain Mapping is source of these problems, but it brings no solution to it.

So, can anyone help me or got any idea how to make site bloking (is_user_logged_in()) work on Multisite network with Domain Mapping plugin enabled?

2 Answers 2


I don’t have the domain mapping on a test installation at hand currently, but what should work is:

add_action( 'template_redirect', 'auth_redirect' );

As a plugin here: T5 Force Log In.
auth_redirect() is WordPress’ native handler for authentication, if it doesn’t work, something is broken in core code.

  • This also doesen't work. The only difference is, that after login, I'm not redirected to Dashboard, but back to login page (but without any error, which means -- as I assume -- that login was successful, only login cookie was not stored correctly). From the support forum thread I assume, that the problem is not in core code, but rather Domain Mapping plugin is interferencing somehow.
    – trejder
    Commented Nov 9, 2012 at 22:11
  • Maybe the problem is that login cookie is set for incorrect domain. If you have Domain Mapping plugin enabled, it will always redirect browser to declared domain. So, for example, I have one.page.com site, mapped to one.com domain. Whenever I enter one.page.com URL, I'm redirected to one.com domain, if Domain Mapping plugin is enabled. Wordpress problably writes down login cookie for one.page.com, which is not available for one.com and everything fails. Dashboard is always accessible under one.page.com (plugin is enabled only for frontend), so this works fine.
    – trejder
    Commented Nov 9, 2012 at 22:15
  • 1
    Issue reported in Domain Mapping plugin support forum.
    – trejder
    Commented Nov 9, 2012 at 22:27

You can use the plugin Authenticator, it works with Multisite too.
If you publish different parts of content via oauth or a kex, the use the development version.

  • Have you read my comments above, to toscho's answer? The problem is not in Multisite, but with Domain Mapping plugin enabled. I'm pretty sure, even without testing, that even Authenticator will fail in this situation. Simply because Wordpress itself fails, as it records login cookie for a different domain then is actually used (after redirection done by Domain Mapping).
    – trejder
    Commented Nov 10, 2012 at 14:55
  • Yes, I Have read this; but I use the plugin in a MU with Domain-Mapping.
    – bueltge
    Commented Nov 13, 2012 at 12:01
  • Problem has been solved. All I needed to do, was to switch main domain of each site from default subdomain address to top-level domain that is mapped to that site, through Domain Mapping. I think that now all force-login plugins should work, but I decided to use underConstruction plugin, as it best fit my needs. Thanks.
    – trejder
    Commented Nov 13, 2012 at 22:22

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.