WordPress.org

Ready to get started?Download WordPress

Forums

Where to use template tags wp_login_url & wp_logout_url (5 posts)

  1. n8steve
    Member
    Posted 3 years ago #

    At present, if a user (subscriber role) logs in to my site using the
    login in the footer, they will get redirected to the WordPress manage
    profile page rather than back to the page where they logged in on the
    site. Similarly on logout, you get taken to the WordPress login rather
    than back to the site. Neither is very user-friendly so I want to
    change it.
    Reading round, it seems the template tags wp_login_url and
    wp_logout_url are what I need to use, I can find the syntax I need to
    use but not where it needs to be inserted.
    I'm a newbie(relatively)and so far have managed everything using the theme, plugins and widgets so adding code and where it needs to be changed is new. Help please!

  2. MichaelH
    Member
    Posted 3 years ago #

  3. n8steve
    Member
    Posted 3 years ago #

    Dear Michael, Many thanks. I finally got time to try this out. With the addition of the code suggested by Peter (see below) to redirect users to the home page on logout, it does exactly what I wanted. Much appreciated. Steve

    function redirect_logout_front_page() {
    wp_redirect(get_option('siteurl'));
    die();
    }

    add_action('wp_logout', 'redirect_logout_front_page');

  4. Luke Gedeon
    Member
    Posted 3 years ago #

    MichaelH and n8steve,

    Thanks! That bit of code was exactly what I needed.

  5. brasofilo
    Member
    Posted 2 years ago #

    thanks guys, pretty useful!

Topic Closed

This topic has been closed to new replies.

About this Topic