WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a question and a technical issue in wordpress. That is, i have a login form on my website to allow visitors to login to see special content. The question goes here, when the time they log in, i am managed to redirect them to a targeted page. When the time they logging out from the member zone, i am out of idea how to send them to a different targeted page.

In my function.php file, I have this code:


How to add the page url that i want to redirect them to this code above? I am just beginner in php. Hope to get some guidance.

share|improve this question
up vote 2 down vote accepted

home_url() will accept a parameter that will be used in the creation of the URL.

The bare minimum solution would be:


site_url() will also accept the same parameter and may be (probably is) a better choice.

I believe that using either of those will make the link dependent on permalink settings. I don't think that those function will translate between different settings, though I have not tested that.

I would suggest using get_permalink() with an explicit page/post ID.


Note that you don't need home_url() or site_url() since get_pemalink() will generate the complete URL.

share|improve this answer
Hi You got it work now. Thank you very much! I will remember this guidance. Thank you! =) – Jornes Aug 11 '13 at 17:28
While it is a good idea to remember, you would want to accept the answer, if it was helpful to you. – Johannes Pille Aug 11 '13 at 17:36
Johannes Pille, excuse me! I did not know about this. But i just did it. Thank you! – Jornes Aug 14 '13 at 15:20

First i think will be better to


Can instead be replaced to look like this

function wpse_109694(){
   $redirect_to = home_url();

add_action('wp_logout', 'wpse_109694');

Once this change is done , you will see that to redirect to another page of your choice , you just edit the $redirect_to variable to the url of the page you need.

share|improve this answer
Hansy Schmitt, thank you for your answer, too! But, i am wondering what is the code 'wpse_109694' for? Is that code redirecting user back to the current page after they have logged out? Hope to get your answer soon. – Jornes Aug 14 '13 at 15:23
Actually is the same code you used, but i expanded so it looked easier for you to understand. In this case , you should only change the variable name $redirect_to to match where you want the page to be redirected ( for example , if we take s_ha_dum sample , i would use $redirect_to = get_permalink(1) or $redirect_to = home_url("/path/to/page") ) – Hansy Schmitt Aug 14 '13 at 17:21
Lol...i see! Hansy, i tried to use .get_permalink(1) in the code, but it redirected me to a post page instead of previous page where i was. I find no way how to fix that then i have created a logout page where they will be redirected after logged out. – Jornes Aug 14 '13 at 18:49

Your Answer


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.