I've been following this guide on how to change your login url : https://www.malcare.com/blog/change-wordpress-login-url/

However, upon adding the logout, login and lost password hooks, I've noticed that I cannot log out anymore. Whenever I log out, it just redirects me to /wp-admin without logging me out.

How can I fix these issues?

1 Answer 1


I think the article's logout hook is wrong on two or three counts:

  • it needs ?action=logout, similar to the lost password link
  • it needs a generated nonce too
  • it doesn't respect the $redirect argument.

Here's a new version based on the current wp_logout_url() code:

add_filter( 'logout_url', 'my_logout_page', 10, 2 );
function my_logout_page( $logout_url, $redirect ) {
    $args = array();
    if ( ! empty( $redirect ) ) {
        $args['redirect_to'] = urlencode( $redirect );

    $logout_url = add_query_arg( $args, site_url( 'my-secret-login.php?action=logout', 'login' ) );
    $logout_url = wp_nonce_url( $logout_url, 'log-out' );

    return $logout_url;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.