I have a wordpress site works good over than 3 years. Recently I actived https for it. After that, when I visit the dashboard, I always be redirected to login page.
I found this on Codex:
Secure HTTPS
If you are having a problem with secure HTTPS, change the following line in wp-includes/vars.php from:
define('COOKIEPATH', preg_replace('|http://[^/]+|i', '', get_settings('home') . '/' ) );
To:
define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) );
Be sure also to change the URL in OPTIONS to https://.
But I cannot find define('COOKIEPATH', preg_replace('|http://[^/]+|i', '', get_settings('home') . '/' ) );
in the vars.php
. My wordpress's version is 4.7.
In the functions.php
, I use this action to prevent users visit the dashboard:
add_action('init', 'IUI_prevent_backend');
function IUI_prevent_backend() {
global $pagenow;
if($pagenow == 'wp-login.php') {
$page = home_url('/login');
} elseif (is_admin() && !(defined('DOING_AJAX') && DOING_AJAX) && !current_user_can('edit_posts') && !current_user_can('edit_events')) {
$page = home_url('/login');
}
wp_redirect($page);
}
I tried to remove this action and nothing changes. I don't think it's the case.