Does anyone know of a good plugin that permits logging in once as the WP-MS network Super Admin and being able to switch sites without having to re-login into each network and/or each site individually?
Thanks
This has to do with the cookie domain. It is set for each domain, which prevents network-wide logins. You can try setting COOKIE_DOMAIN
constant in your wp-config.php
.
For example setting it to empty, which prevents WordPress from changing the cookie domain for each site:
define( 'COOKIE_DOMAIN', '' );
Maybe you need to set some other constants too, to make it work.
define( 'ADMIN_COOKIE_PATH', '/' );
define( 'COOKIEPATH', '' );
define( 'SITECOOKIEPATH', '' );
Don't ask me about drawbacks, because I'm not entirely sure about that.
Or you can set one specific cookie domain for all sites:
define( 'COOKIE_DOMAIN', 'example.com' );
define( 'ADMIN_COOKIE_PATH', '/' );
define( 'COOKIEPATH', '/' );
define( 'SITECOOKIEPATH', '/' );
It probably is a good idea to set a unique cookie hash too:
define( 'COOKIEHASH', 'unique_cookie_hash_string' );
In case you have other WordPress installations using the same domain for cookies.
Update:
From the GitHub page of WP Multi Network I got this:
Single Sign-on
Stash something similar to this in your
wp-config.php
to share cookies across all sites & networks.
// Cookies
define( 'COOKIEHASH', md5( 'yourdomain.com' ) );
define( 'COOKIE_DOMAIN', 'yourdomain.com' );
define( 'ADMIN_COOKIE_PATH', '/' );
define( 'COOKIEPATH', '/' );
define( 'SITECOOKIEPATH', '/' );
define( 'TEST_COOKIE', 'thing_test_cookie' );
define( 'AUTH_COOKIE', 'thing_' . COOKIEHASH );
define( 'USER_COOKIE', 'thing_user_' . COOKIEHASH );
define( 'PASS_COOKIE', 'thing_pass_' . COOKIEHASH );
define( 'SECURE_AUTH_COOKIE', 'thing_sec_' . COOKIEHASH );
define( 'LOGGED_IN_COOKIE', 'thing_logged_in' . COOKIEHASH );
From the looks of it, it is generic WordPress stuff, not plug-in specific, so it might be worth a try. Could be, we haven't done enough so far.
define('COOKIE_DOMAIN', ''); define('ADMIN_COOKIE_PATH', '/'); define('COOKIEPATH', ''); define('SITECOOKIEPATH', '');
define('COOKIE_DOMAIN', 'my-main-wp-network-site.com'); define('ADMIN_COOKIE_PATH', '/'); define('COOKIEPATH', '/'); define('SITECOOKIEPATH', '/');
@tammy it doesn't. If you have a dozen different network setups then there is no safe and secure way to log in to all of them at once. If they are a dozen sites on 1 WP install then when you log in you should be logged in across a single network.
– Alex Older Aug 5 at 10:35
As of Wordpress 4.2.4, a bone stock multi-site installation with MU Domain Mapping 0.5.5 Development Plugin and Multisite User Managment Plugin 1.1, logging in through the primary domain will log a user in to all sites the user is assigned to (all sites as super admin user). However, the user has visit a child site to establish the cookie and auth, which will be done automatically. Fortunately, you can include a workaround to log a user out of all sites if any child site has been visited while auth'ed on the primary domain. Currently I have found it doesn't log you out of all sites by default. Here is what you can add to your functions.php file in your theme which will destroy the users sessions network wide on log-out below:
function clear_session_on_logout() {
$current_user = wp_get_current_user();
// get all sessions for user with ID $user_id
$sessions = WP_Session_Tokens::get_instance($current_user->ID);
// we have got the sessions, destroy them all!
$sessions->destroy_all();
}
add_action('clear_auth_cookie', 'clear_session_on_logout');
It is also a good idea to update your network wide theme, or themes used throughout the child sites to log-in and log-out with the primary domain's wp-admin/. However if you require the user to log-out from each child site "if visited" while logged into the primary domain, then the default log-out hook will suffice.
FYI: If you log into a child site with Super Admin Account, it will not log you in to every site. I think this is by design, and quite simply an easy fix by modifying the theme's login and log-out hook to always use the primary domain. If you prefer to redirect back to the child domain on log-in and log-out, a simple hook can be done for this as well.
networks
...not just sites
within each network
. So I have begin to write my own login to make that happen since I cannot seem to find one out there that does it.