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()
{
if(!is_user_logged_in())
{
echo('No way, man!');
die();
}
}
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?
I donât have the domain mapping on a test installation at hand currently, but what should work is:
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.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.