Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using some code that I found here in order to create a login/logout form on my sidebar. The login works just fine, but what's weird is that on logout, the user gets redirected to "personaldomain.com/%2F", and I get an error that says

Not Found

The requested URL // was not found on this server.

The code for the logout button is:

<a href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>">logout</a><br />

Any advice?

share|improve this question
1  
What happens if you do not use urlencode() which is used anyway in wp_logout_url()s internal code? –  toscho Jun 12 '12 at 12:30
add comment

1 Answer

According to the codex.. this part:

urlencode($_SERVER['REQUEST_URI'])

.
is unneeded... if you just wan't to logout (pasting from wordpress codex)

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

.

Logout and Redirect to Current Page

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

.
Logout and Redirect to Homepage

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

.
Hope this helps... should always check the codex first ;)

Have a gr8 day,
Sagive

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.