• Is there a way that after you log out of the WP Admin, the URL will return to the site domain and not the logout URL?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @scottkr24,

    By default, WordPress will redirect them to the login page of your website, but we can easily change it by adding following snippet to current theme’s functions.php file:

    add_action('wp_logout','kk_auto_redirect_after_logout');
    function kk_auto_redirect_after_logout() {
      wp_redirect( 'https://www.example.com' );//URL you want to redirect
      exit();
    }

    Thanks,
    Kakshak

    Thread Starter scottkr24

    (@scottkr24)

    Thanks, I’ll give it a try.

    Thread Starter scottkr24

    (@scottkr24)

    It didn’t work.

    Try this:

    add_filter( 'logout_url', 'kk_auto_redirect_after_logout' );
    function kk_auto_redirect_after_logout( $default ) {
        // set your URL here
        return is_admin() ? 'https://example.com/custom' : $default;
    }

    Thanks,
    Kakshak

    Thread Starter scottkr24

    (@scottkr24)

    Didn’t work either.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WP-admin’ is closed to new replies.