Login Loop WordPress Network Admin

WP loginThis article referred to the Network Admin login loop as experienced on WordPress 3.5.1 in subdomain Network mode. Not to be confused with the Site Admin login loop when WP is running in Single mode, although some of the early troubleshooting steps suggested here apply to both types of login loops. Manually requesting the Network Admin login URL could look similar to http://domain.tld/wp-admin/network/. which gets you to http://domain.tld/wp-login.php as seen in your browser location bar. This is as far as you can get. This loop can discourage, but you are not far from logging in to the Network Dashboard. Your network is installed and your WP is accessing the database as planned.

Login Loop Symptom:

  • you may have logged into the Site Dashboard using http://domain.tld/wp-admin/
  • the loop presents itself when getting into the Network Dashboard
  • Entering correct login credentials, the login loop just ‘refreshes’ the login page. If wrong credentials were entered, WP is kind enough to indicate that above the login form
  • request w/FF or IE http://4assistance.com/wp-login.php redirects to http://4assistance.com/wp-login.php?redirect_to=http%3A%2F%2F4assistance.com%2Fwpress%2Fwp-admin%2F&reauth=1 (note physical folder /wpress), had ff browser tabs open, failed login logs out the one logged in

Causes:

  • Web browser history can illicit the login loop, especially when first installing your Network. Your Network Dashboard is configured to work, you browser is keeping you from getting to it.
  • You may have done one or more of the following: moved your WP install, changed url rewriting, changed domain names, edited your wp-config.php.

Breaking the Loop:

Preliminary Steps

  • Eliminate the simple first.
  • Clear browser cache, including cookies for your domain.tld.
  • For your web browser, check out ‘Private’ browsing. It does not save any history when you quit, especially useful during setting up any WP.
  • Confirm the follow two lines in wp-config are correct, because when either is defined, they will override the corresponding record in the wp_site database table
    define('DOMAIN_CURRENT_SITE', 'domain.tld');
    define('PATH_CURRENT_SITE', '/');
  • Try commenting them out, one at a time. Perhaps the records in the database are correct.

Technical Inspection

  • Two database tables added by installing Network, wp_blogs & wp_site each have two fields that must be the same in both tables. Once in a while domain and path can be changed in one table and not the other.
  • Function wp_redirect( ) will be called if this is true, and what the browser sees is the login page refreshed.
  • You will have to be able to edit your database using a client like phpMyAdmin to continue. Failing that, you still have options like hiring professional help, or attempting another installation of WP and Network.
  • To inspect these fields, following are a couple of options: edit an admin.php file, or run our one line sql against you db, or manually compare them using your favorite database client

admin.php file method

  • If you’d like to see your two domains and paths, the way your WP sees them, insert the php code below in the: /wp-admin/network/admin.php
  • Find around line 16 the line that reads “wp_die( __( ‘Multisite support is not enabled.’ ) );” Insert the code that follows, just below this line.
# begin flail
/*  <- prepend this line with # as in "#/*" to activate this flail (also the one below)
$blog_dom = '$current_blog->domain: "'.$current_blog->domain.'"';
$site_dom = '$current_site->domain: "'.$current_site->domain.'"';
$blog_path = '$current_blog->path: "'.$current_blog->path.'"';
$site_path = '$current_site->path: "'.$current_site->path.'"';
$same = 'This is good, some other config is causing the problem, url rewrite, PATH_CURRENT_SITE not /';
$diff = 'These are different, we need to change something';
$dom_same = ( $current_blog->domain != $current_site->domain ) ? "$blog_dom NOT equal $site_dom, fix required" : "$blog_dom EQUAL to $site_dom, no problem here";
$path_same = ( $current_blog->path != $current_site->path ) ? "$blog_path NOT equal $site_path, fix required" : "$blog_path EQUAL to $site_path, no problem here";
echo "<h3>[".basename(__FILE__)."][".__LINE__.'] '.$dom_same.'</h3>';
echo "<h3>[".basename(__FILE__)."][".__LINE__.'] '.$path_same.'</h3>';
exit;
*/  <- prepend this line with # as in "#*/" to activate this flail
# end flail
  • In your browser, request http://your.main.site.domain.tld/wp-admin/network/ and you should see the results of the above test
  • If your WordPress or URL rewrite by web.config or .htaccess is bad, and you installed WordPress in a separate folder, include that folder name in the above URI

one line sql query method

  • Use your favorite database client to run the following sql
SELECT b.domain AS 'blogs-domain', s.domain AS 'site-domain', b.path AS 'blogs-path', s.path AS 'site-path' FROM wp_blogs AS b, wp_site AS s WHERE b.blog_id = 1 AND s.id = 1 LIMIT 1;
  • Expect output something like this with the command-line mysql client: I hope yours is less messed up than this example.
+-----------------+-------------+------------+-----------+
| blogs-domain    | site-domain | blogs-path | site-path |
+-----------------+-------------+------------+-----------+
| domain.org      | wrong.com   | /          | /blog     |
+-----------------+-------------+------------+-----------+
  • Remember that the two wp_site table records (wrong) above, can be overridden if defined in wp-config as below:
    define('DOMAIN_CURRENT_SITE', 'domain.tld');
    define('PATH_CURRENT_SITE', '/');

Manually Inspect (Browse) database

table wp_site

  • should only have 1 record
  • if needed, edit fields domain and path
  • ie. domain “domain.tld”, and path “/”

table wp_blogs

  • focus on record with blog_id equal 1 for now
  • if needed, edit fields domain and path

table wp_sitemeta

  • find meta_key ‘siteurl’ usually meta_id 14
  • ‘siteurl’ has to be the URL to your physical WP install without trailing slash
  • ie. if WP installed in domain root, then this is just a link to your domain, but if WP is installed in its own subfolder, append the path to that folder

 

Leave a comment

Your email address will not be published. Required fields are marked *

26 − 25 =