• I am using a Theme that has a custom login/registration page. After a user clicks the logout button, they are redirected to the standard Wp-Admin login page. Is there a snippet of code I can use to redirect users back to the home page instead of to the WordPress login page?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You should ask in the theme’s support forum, if it’s really the theme doing that. (Usually that is a plugin.)

    An information which theme you are using might help.
    You can try to add this code to your functions.php file.

    add_filter( 'logout_url', 'custom_logout_page', 10, 2 );
    function custom_logout_page( $logout_url, $redirect ) {
    return '<the-URL-you-want-to-end';
    }

    If this does not work you can also change the general-template.php
    Keep in mind that you do not find it in the wp-admin area, but you have to use FTP or WebFTP to find it.
    You find it in the WP-includes folder

    Search there for this code:
    function wp_logout_url

    right below it, you’ll find a return statement.
    When you specify this, you also change the logout url.
    I would definitely recommend you to create a copy of the general-template.php before you start editing.

    • This reply was modified 5 years, 10 months ago by bb23.
    Moderator t-p

    (@t-p)

    Side note to @bb23 ,

    I wouldn’t recommend messing with the core files.

    Why?

    Modifications of the core files can cause:

    – security risks,
    – performance degradation,
    – broken plugins/themes,
    – you will lose all changes when you next update the WordPress, etc.

    If there are no hook present in a function you want to modify, it’s better to copy the function you need and change it in your Child Theme or plugin, rather than modifying the core files directly.

    Thus, as the adage goes, don’t modify core files and please be aware of the limitations and drawbacks this imposes.

    • This reply was modified 5 years, 10 months ago by t-p.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirect to page other than Wp-Admin after log out?’ is closed to new replies.