我正在使用wordpress 4.6。
我有带有页面URL domain-name/account/?action=register的模板注册表单
我想在注册后将它重定向到主页,但它不会显示
留言“你已经登录了,你最好去主页”,带有网页URL
domain-name/account/?result=registered.我已经在主题functions.php中尝试了下面的代码
function __my_registration_redirect(){
wp_redirect( '/my-account' );
exit;
}
add_filter( 'registration_redirect', '__my_registration_redirect' );但什么都没发生
发布于 2016-12-21 07:11:59
与其使用代码,不如在法典例中尝试哪一种。
这个简单的示例将在成功注册后将用户重定向到home_url()。
add_filter( 'registration_redirect', 'my_redirect_home' );
function my_redirect_home( $registration_redirect ) {
return home_url();
}发布于 2017-01-25 16:06:01
您可以尝试下面的代码进行登录和注销重定向。
// -- LOGIN | LOGOUT STUFF -- functions.php
//add_filter('user_register', 'login_redirect');
add_filter('wp_login', 'login_redirect');
function login_redirect($redirect_to) {
wp_redirect( home_url() );
exit();
}
add_action('wp_logout','logout_redirect');
function logout_redirect(){
wp_redirect( home_url() );
exit();
}
/* END */https://wordpress.stackexchange.com/questions/249918
复制相似问题