After logging on to or logging out of WordPress, return to the previously accessed page.

Source: Internet
Author: User

First, we get the address of the currently accessed page:

$ Url_this = 'http: // '. $ _ SERVER ['server _ name']. $ _ SERVER ["REQUEST_URI"];

Then add the address as the parameter in the login and logout functions:

// Log on <? Php echo wp_login_url ($ url_this);?> // Logout <? Php echo wp_logout_url ($ url_this);?>

In this way, the previously accessed page will be returned after logon or logout.

If you use the default logon form in the background, you can add a link to the logon page at the foreground:

<? Php $ url_this = 'http: // '. $ _ SERVER ['server _ name']. $ _ SERVER ["REQUEST_URI"];?> <A href = "<? Php echo wp_login_url ($ url_this);?> "> Logon </a> <a href =" <? Php echo wp_logout_url ($ url_this);?> "> Logout </a>

If you are using a custom login form at the front-end, you can use the following:

<? Php $ url_this = 'http: // '. $ _ SERVER ['server _ name']. $ _ SERVER ["REQUEST_URI"];?> // Log on to <form class = "user-login" name = "loginform" action = "<? Php echo wp_login_url ($ url_this);?> "Method =" post "> <input class =" my-login "type =" text "name =" log "value =" "/> <input class =" my-login "type =" password "name =" pwd "value =" "/> <input class =" login-btn "type =" submit "name =" submit "value =" log on "/> </form> // log out <a href =" <? Php echo wp_logout_url ($ url_this);?> "> Logout </a>

The above is how to modify the logon or logout of WordPress and return to the previously accessed page for your reference.

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.