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 badges
Add a comment  | 

2 Answers 2

Reset to default 2

Instead 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