WordPress redirects to the specified page after logging out.

Source: Internet
Author: User
Tags exit in

This problem is also well solved. Just put the following php code in functions. php of the current topic:

The code is as follows: Copy code

Add_filter ('logout _ url', 'ludou _ logout_redirect ', 10, 2 );

Function ludou_logout_redirect ($ logouturl, $ redir ){
$ Redir = 'http: // www.111cn.net/'; // enter the URL you want to jump.
Return $ logouturl. '& amp; redirect_to ='. urlencode ($ redir );
}

In this way, you can click exit in the upper-right corner of the background page to jump to the specified page. If you want to add an exit link at the front-end, click it to log out and jump to the specified site page, you can use the following code (the URL in the code is changed to yours ):

The code is as follows: Copy code

<? Php if ($ user_ID) {?>
<A href = "<? Php echo wp_logout_url ('http: // www.111cn.net/');?> "Title =" Logout "> Logout </a>
<? Php }?>

To jump to the homepage, you can use the following code:

The code is as follows: Copy code

<? Php if ($ user_ID) {?>
<A href = "<? Php echo wp_logout_url (home_url ();?> "Title =" Logout "> Logout </a>
<? Php }?>

To jump to the page before exiting, use the following code:

The code is as follows: Copy code

<? Php if ($ user_ID) {?>
<A href = "<? Php echo wp_logout_url (home_url (add_query_arg (array (), $ wp-> request);?> "Title =" Logout "> Logout </a>
<? Php }?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.