38814

Wordpress - /wp-admin/ redirecting to /wp-login.php, when logged-in

Question:

When logged-in wp-admin is redirecting to wp-login.php via 302.

<hr />

There are 2 behaviours:

1) Username/password correct. 302 redirect to /wp-admin/ followed by a 302 redirect to /wp-login.php

2) Username/Password entered is wrong, no redirect. 200 response with "ERROR: Incorrect username or password." displayed.

<hr />

Wordpress configuration (I've replaced the real domain with "testdomain.com"):

$_SERVER['HTTPS']='on'; define( 'FORCE_SSL_LOGIN', false ); define( 'FORCE_SSL_ADMIN', false ); if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); //$currenthost = "https://".$_SERVER['HTTP_HOST']; $currenthost = "https://exampledomain.com"; $currentpath = preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])); $currentpath = preg_replace('/\/wp.+/','',$currentpath); define('WP_HOME',$currenthost.$currentpath); define('WP_SITEURL',$currenthost.$currentpath); define('WP_CONTENT_URL', $currenthost.$currentpath.'/wp-content'); define('WP_PLUGIN_URL', $currenthost.$currentpath.'/wp-content/plugins'); define('DOMAIN_CURRENT_SITE', $currenthost.$currentpath ); define('ADMIN_COOKIE_PATH', './'); define('WP_BASE', $currenthost.$currentpath); define('FS_METHOD', 'direct'); define('FS_CHMOD_DIR', (0705 & ~ umask())); define('FS_CHMOD_FILE', (0604 & ~ umask())); <hr />

Any ideas?

Answer1:

If you are sure that your login credentials are correct, you can make use of the "wp_authenticate" hook as follows:

add_action('wp_authenticate', 'mysite_check_already_logged_in'); function mysite_check_already_logged_in() { if (is_user_logged_in()) { wp_redirect(site_url('wp-admin')); } }

Recommend

  • htaccess will not rewrite subdomains
  • Wordpress and Drupal SSO/Single Sign On
  • wordpress query - next two events by metadata date
  • DOMXML, PHP4 => PHP5
  • IIS 7.5 404 Error for .PDF files
  • Accessing Windows Azure Queues from client side javascript/jquery
  • Weighted round robin dns between 2 Cloudfront distributions
  • proxy request in node.js / express
  • textIndicatorPrecision in dojox.dgauges using dojo
  • numpy 64bit support in PTVS and numpy System.Int64 casting
  • ng-repeat not working with table but works with list
  • PHP Copy function not working
  • css background images not always displayed
  • Cordova Apache wrong module path
  • What is the reason that Policy.getPolicy() is considered as it will retain a static reference to the
  • Want to understand iframe breakout code
  • You tube videos are not playing
  • Correct implementation of List Iterator methods
  • jwtBearer bearer token with rc-1 update to ASP.Net 5
  • Spring Cloud Microservice Architecture Confusion
  • Breaking out column by groups in Pandas
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • AJAX Html Editor Extender upload image appearing blank
  • Time complexity of a program which involves multiple variables
  • Email verification using google app script and google forms
  • How can I send an e-mail from a vbs script
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Window Size for Mac application
  • Is there a mandatory requirement to switch app.yaml?
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Getting error when using KSoap library to consume .NET web services
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • UserPrincipal.Current returns apppool on IIS