0

I want to create Custom Login, Registration, Password Reset & Logout Page. For that I have added following code in my function.php file.

function custom_login_page() {
 $new_login_page_url = home_url(); // new login page
 global $pagenow;
 if( $pagenow == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET' ) {
    wp_redirect($new_login_page_url);
    exit;
 }
}
 add_action('init','custom_login_page');

Everything is working perfectly except the logout process. By adding this code a user is not getting logged out.

In short the Logout Process is not working. Plz Help.

Thanks

0

You might have to trigger wp_logout() yourself in that case:

if ( $pagenow == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET' ) {
    if ( (isset($_GET['action'])) && ($_GET['action'] == 'logout') ) {
        wp_logout();
    }
    wp_redirect($new_login_page_url);
    exit;
}

That said, it sounds like a real pain to reinvent wp-login.php and handle the different form actions etc... a plugin such as Theme My Login might be more suitable for a more bug-free solution.

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.