我已经创建了一个自定义登录页login.php
在根部内部。(例如:http://www.example.com/login.php
)
/*
LOGIN PAGE.
*/
// Login URL.
function custom_login_url($login_url, $redirect, $force_reauth ) {
$login_url = home_url( \'login.php\', \'login\' );
if ( ! empty( $redirect ) ) {
$login_url = add_query_arg( \'redirect_to\', urlencode( $redirect ), $login_url );
}
if ( $force_reauth ) {
$login_url = add_query_arg( \'reauth\', \'1\', $login_url );
}
return $login_url;
}
// Lostpassword URL.
function custom_lostpassword_url( $lostpassword_url, $redirect = \'\') {
$args = array(
\'action\' => \'lostpassword\',
);
if ( ! empty( $redirect ) ) {
$args[\'redirect_to\'] = urlencode( $redirect );
}
if ( is_multisite() ) {
$blog_details = get_blog_details();
$wp_login_path = $blog_details->path . \'login.php\';
} else {
$wp_login_path = \'login.php\';
}
$lostpassword_url = add_query_arg( $args, network_home_url( $wp_login_path, \'login\' ) );
return $lostpassword_url;
}
add_filter( \'lostpassword_url\', \'custom_lostpassword_url\', 20);
// Registration URL.
function custom_registration_url() {
return home_url( \'login.php\' . \'?action=register\', \'login\' );
}
// Custom redirect admin locations.
function custom_redirect_admin_locations() {
global $wp_rewrite;
if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) ) {
return;
}
$admins = array(
home_url( \'admin\', \'relative\' ),
);
if ( in_array( untrailingslashit( $_SERVER[\'REQUEST_URI\'] ), $admins, true ) ) {
wp_redirect( admin_url() );
// wp_redirect( home_url( ADASTRA_ADMIN_PAGE) );
exit;
}
$logins = array(
home_url( \'login\', \'relative\' ),
);
if ( in_array( untrailingslashit( $_SERVER[\'REQUEST_URI\'] ), $logins, true ) ) {
wp_redirect( wp_login_url() );
exit;
}
}
// Custom Logout URL.
function custom_logout_url($logout_url, $redirect = \'\') {
$args = array();
if ( ! empty( $redirect ) ) {
$args[\'redirect_to\'] = urlencode( $redirect );
}
$logout_url = add_query_arg( $args, home_url( \'login.php\' . \'?action=logout\', \'login\' ) );
$logout_url = wp_nonce_url( $logout_url, \'log-out\' );
return $logout_url ;
}
function custom_set_login_url() {
add_filter( \'login_url\', \'custom_login_url\', 10, 3 );
add_filter( \'logout_url\', \'custom_logout_url\', 15, 2 );
add_filter( \'register_url\', \'custom_registration_url\', 30 );
remove_action( \'template_redirect\', \'wp_redirect_admin_locations\', 1000 );
add_action( \'template_redirect\', \'custom_redirect_admin_locations\', 1100 );
}
add_action(\'init\', \'custom_set_login_url\', 9999);
现在,所有URL都工作正常,但每次有新用户注册或放弃密码时,他都会收到一封带有两个链接的电子邮件:
指向;“错误”;(又名默认)登录页面:
http://www.example.com/wp-login.php?action=rp&key=rMrHUdWY1NC1eDdHAc4e&login=averagejoe
指向正确登录页的链接:
http://www.example.com/login.php
系统怎么可能不使用我提供的自定义URL,我只需要一个指向自定义登录页的确认/激活链接,如:
http://www.example.com/login.php?action=rp&key=rMrHUdWY1NC1eDdHAc4e&login=averagejoe
不使用插件。
有人能帮我吗?
谢谢