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.