2

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

2

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.

  • That did not work @ialocin. I logged into my WP Core/Base network. Then when I switched networks I was presented with the login screen again. – tammy Jul 31 '15 at 20:39
  • Too bad, I added some additional information to my answer. I hope it helps, because otherwise I personally can't tell you more. The rest you have to try and research yourself. @tammy – Nicolai Aug 2 '15 at 8:39
  • Ok, thanks @ialocin -- I'll give those a try and post back – tammy Aug 3 '15 at 12:13
  • 1
    Test #1 (code below) -- this did not work. I successfully logged into the main/core network as the Super Admin. Then when I switched networks I was presented with the login screen. define('COOKIE_DOMAIN', ''); define('ADMIN_COOKIE_PATH', '/'); define('COOKIEPATH', ''); define('SITECOOKIEPATH', ''); – tammy Aug 3 '15 at 12:49
  • 1
    Test #2 (code below) -- this did not work either. I successfully logged into the main/core network as the Super Admin. Then when I switched networks I was presented with the login screen. define('COOKIE_DOMAIN', 'my-main-wp-network-site.com'); define('ADMIN_COOKIE_PATH', '/'); define('COOKIEPATH', '/'); define('SITECOOKIEPATH', '/'); – tammy Aug 3 '15 at 12:51
2

@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

  • Thanks @AlexOlder -- for this is the answer to my question... – tammy Aug 17 '15 at 14:07
0

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.

  • Also, I have found it annoying with the default "My Sites" drop down in the wp-admin bar, it sends you to the child site's wp-admin/ which triggers any user (including super admin) to log in again to the child site even if already auth'ed on the primary domain (strange). If you visit any other page other than the wp-admin/ directory of a child site, a user will be auth' automatically and the admin-bar will appear. A simple fix in the wp-admin bar is to change the links in the drop down to go to site_url(); of the child site. – Zach Goldsmith Aug 7 '15 at 15:17
  • Thanks @ZachGoldsmith for chiming in in this. I am looking for a single sign-on to all of my 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. – tammy Aug 7 '15 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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