Redirecting wp-login.php makes log in button keep redirect to the same custom lo
-
I have copied wp-login.php code in a template file in my theme Created a new page and assigned the template /login
Added the following code in function.php
// Hook the appropriate WordPress action add_action('init', 'prevent_wp_login'); function prevent_wp_login() { // WP tracks the current page - global the variable to access it global $pagenow; // Check if a $_GET['action'] is set, and if so, load it into $action variable $action = (isset($_GET['action'])) ? $_GET['action'] : ''; // Check if we're on the login page, and ensure the action is not 'logout' if ($pagenow == 'wp-login.php' && (!$action || ($action && !in_array($action, array('logout', 'lostpassword', 'rp', 'resetpass'))))) { // Load the home page url $page = '/login'; // Redirect to the home page wp_redirect($page); // Stop execution to prevent the page loading for any reason exit(); } }
the page keeps directing me to the login after pressing the login button
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Redirecting wp-login.php makes log in button keep redirect to the same custom lo’ is closed to new replies.