Authenticate Subdomain
I have a sub-domain which I'm trying to restrict to authenticated Wordpress users but the authentication isn't working. I've tried the following code:
global $current_user;
wp_get_current_user();
if ( is_user_logged_in() ) {
echo 'Username: ' . $current_user-user_login . \n;
echo 'User display name: ' . $current_user-display_name . \n;
} else {
wp_loginout();
}
This works if I use the URL domain.com/intranet/page.php but not on intranet.domain.com/page.php How can I get it to work for subdomains? I've tried adding the following to wp-config.php but that hasn't done anything:
define('COOKIE_DOMAIN', '.domain.com'); // Used to authenticate subdomains
define('COOKIEPATH', '/');
Any ideas?
Topic authentication Wordpress
Category Web