admin管理员组文章数量:1292119
I am using wordpress 4.6.
I have template register form with page URL domain-name/account/?action=register
I want to redirect it to home page after register but instead of that it show
message "You have logged in. You better go to Home" with page URL
domain-name/account/?result=registered.
I already try below code in theme functions.php
function __my_registration_redirect(){
wp_redirect( '/my-account' );
exit;
}
add_filter( 'registration_redirect', '__my_registration_redirect' );
but nothing happens
I am using wordpress 4.6.
I have template register form with page URL domain-name/account/?action=register
I want to redirect it to home page after register but instead of that it show
message "You have logged in. You better go to Home" with page URL
domain-name/account/?result=registered.
I already try below code in theme functions.php
function __my_registration_redirect(){
wp_redirect( '/my-account' );
exit;
}
add_filter( 'registration_redirect', '__my_registration_redirect' );
but nothing happens
Share Improve this question edited Dec 22, 2016 at 5:16 Pravin asked Dec 21, 2016 at 6:03 PravinPravin 211 silver badge4 bronze badges2 Answers
Reset to default 2Instead of your code why don't you try which in the codex example.
This simple example will redirect a user to the home_url()
upon successful registration.
add_filter( 'registration_redirect', 'my_redirect_home' );
function my_redirect_home( $registration_redirect ) {
return home_url();
}
you can try this code below for log in and log out redirects
// -- 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 */
本文标签: How to redirect to home page after registration
版权声明:本文标题:How to redirect to home page after registration? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741548276a2384725.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论