My WordPress Website welcome email comes as:
Username: xxxxxxxx
To set your password, visit the following address:
https://mywebsite.com/wp-login.php?action=rp&key=xxxxxxxxxxx&login=USERNAME
https://mywebsite.com/wp-login.php
How to change URL Format to my current custom login page:
https://mywebsite.com/MY-CURRENT-LOGIN-PAGE?action=rp&key=xxxxxxxxxxx&login=USERNAME
https://mywebsite.com/MY-CURRENT-LOGIN-PAGE
Thank you.
CodePudding user response:
You can probably use the login_url
(WordPress docs on login_url) hook. Something like below. Just place that code in your theme's function.php file.
add_filter( 'login_url', 'my_custom_login_url', 10, 3 );
/**
* Filters the login URL.
*
* @param string $login_url The login URL. Not HTML-encoded.
* @param string $redirect The path to redirect to on login, if supplied.
* @param bool $force_reauth Whether to force reauthorization, even if a cookie is present.
*
* @return string
*/
function my_custom_login_url( $login_url, $redirect, $force_reauth ){
// This will append /the-url-to-login/ to you main site URL as configured in general settings (ie https://mywebsite.com/the-url-to-login/)
// Replace '/login/' and '/account/' with your desired path.
$login_url = site_url( '/login/', 'login' );
$redirect = site_url( '/account/' );
if ( ! empty( $redirect ) ) {
$login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );
}
return $login_url;
}
Think add_filter
as proof reading and editing. You have some text that is about to be published but you send it to a person to proof read and edit. The edits they make are what actually get published.
When you use add_filter
you can do anything you want with that text. Whatever comes out gets used. You can even ignore the original text and pass along your own.