Problem with Wordpress logout

1 replies
Hello!

I have added a login form to my Wordpress theme using this code:

PHP Code:
<<?php if (!(current_user_can('level_0'))){ ?>
<h2>Login</h2>
<form action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
<input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1?>" size="20" />
<input type="password" name="pwd" id="pwd" size="20" />
<input type="submit" name="submit" value="Send" class="button" />
    <p>
       <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label>
       <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
    </p>
</form>
<a href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword">Recover password</a>
<?php } else { ?>
<h2>Logout</h2>
<a href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>">logout</a><br />
<a href="myurl">admin</a>
<?php }?>
It works like perfect except one thing - when I logout "/" gets changed to "%2F". So if I'm logging out from myurl.com/mypage I get redirected to myurl.com/%2Fmypage%2F.

What causes this problem and how do I solve it?
#logout #problem #wordpress
  • Profile picture of the author Nochek
    <a href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>">logout</a><br />

    That line is using urlencode(), which will turn /'s and other various cahracters into their url-safe equivalents. Try this line instead:

    <a href="<?php echo wp_logout_url($_SERVER['REQUEST_URI']); ?>">logout</a><br />
    Signature
    Nochek Solutions Presents:
    The Hydrurga WSO - Rank Your Site #1 And Score Over The Penguin Updates!
    {{ DiscussionBoard.errors[5527772].message }}

Trending Topics