Forums

[resolved] Redirection after logout (10 posts)

  1. schso
    Member
    Posted 1 year ago #

    Hello,
    I'd like the logout page/action to be followed by the display of the home page, instead of the login/logout WP page.
    I have 2 pages to modify, one includes the todo mini forms plugins.

    This is the code, does anyone know how to redirect to another page ?
    Thanks in advance

    Schso (http://peepchatou.free.fr, and go to Forum)

    <p>Vous êtes <b><?php echo $user_identity; ?></b>. /wp-login.php?action=logout" title="Log out of this account">Se déconnecter</p>

    And for the tdomf form :

    <p>Vous êtes <b>%%USERNAME%%</b>. <?php wp_loginout(); ?></p>

  2. chaoskaizer
    Member
    Posted 1 year ago #

    try

    <?php
    $redirect = '&amp;redirect_to='.urlencode(wp_make_link_relative(get_option('siteurl')));
    $uri = wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' );
    ?>
    <a href="<?php echo $uri;?>"><?php _e('logout');?></a>
  3. schso
    Member
    Posted 1 year ago #

    That's great, thanks a lot.
    New request now this one is solved : I am in a post (no longer in the home page), how may I redirect where I am instead of the home page ?

    Thanks again, it's much better now !

    Schso

  4. schso
    Member
    Posted 1 year ago #

    Ice on the cake, I have the same redirection to do when I login from a post page.

    <p>Veuillez préciser votre nom et votre adresse mail. Vous pouvez vous connecter si vous êtes un membre du bureau de l'association.</p>

    I'd like to stay in the post page instead of going to the home page of the blog.

    It would be nicer this way, but it's already gread.
    Thanks,

    Schso

  5. schso
    Member
    Posted 1 year ago #

    oups sorry

    <p>Veuillez préciser votre nom et votre adresse mail. Vous pouvezvous connecter si vous êtes un membre du bureau de l'association.</p>`

  6. chaoskaizer
    Member
    Posted 1 year ago #

    use the following function to get the current url

    <?php
    function self_uri()
    {
    
        $url = 'http';
        $script_name = '';
    
        if (isset($_SERVER['REQUEST_URI'])):
            $script_name = $_SERVER['REQUEST_URI'];
    
        else:
            $script_name = $_SERVER['PHP_SELF'];
    
            if ($_SERVER['QUERY_STRING'] > ' '):
                $script_name .= '?' . $_SERVER['QUERY_STRING'];
    
            endif;
        endif;
    
            if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
                $url .= 's';
    
            $url .= '://';
    
            if ($_SERVER['SERVER_PORT'] != '80'):
                $url .= $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $script_name;
    
            else:
                $url .= $_SERVER['HTTP_HOST'] . $script_name;
    
            endif;
    
        return $url;
    }
    //
    // $redirect = '&amp;redirect_to='.urlencode(self_uri());
    //
    ?>
  7. schso
    Member
    Posted 1 year ago #

    Wow, everything's just fine.
    You have been very helpful, thanks a lot.

    Schso

  8. charlieperrins
    Member
    Posted 9 months ago #

    That's a great tip, thanks very much. Works perfectly in wp 2.7.1

  9. jeffery2k9
    Member
    Posted 8 months ago #

    good , i will give it a try.....thanx

  10. whatshakin
    Member
    Posted 4 months ago #

    which files and where do these lines of code go chaoskaizer?

    I missed something :)

Topic Closed

This topic has been closed to new replies.

About this Topic