Leave a Reply

3 comments

  1. wp_loginout(get_permalink()); will make hyperlink with “Log out/Log in” text and after log out it will stay in the same page, or it will direct user to log in page.

  2. something like this

    function my_redirect(){
        $redirect_url = $_SERVER['HTTP_REFERER'];
        if(!empty($_REQUEST['redirect_to'])){
            wp_safe_redirect($_REQUEST['redirect_to']);
        } else {
            wp_redirect($redirect_url);
        }
        exit();
    }
    add_filter('wp_logout','my_redirect');
    
  3. For example:

    <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>
    

    Can all be done with WP functions – no custom code required in this case.

    You just need to move the code from function.php into the theme and it should work.