1

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

2 Answers 2

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();
}
7
  • Not working for me.
    – Pravin
    Dec 22, 2016 at 3:37
  • Do you using bbPress plugin? Please try this with after disable all plugins. Seems like there is a conflict with the plugin.
    – Ranuka
    Dec 22, 2016 at 11:56
  • Yes I am using bbPress plugin.
    – Pravin
    Dec 22, 2016 at 16:00
  • There is a comfict with bbpress plugin and registration_redirect filter. You can try this code after disble the plugin. If you need to use bbpress ask your question on bbpress forum. Clearly mention the conflict.
    – Ranuka
    Dec 23, 2016 at 0:19
  • Sorry but after deactivating bbpress plugin same problem is there.May it template level handing?
    – Pravin
    Dec 23, 2016 at 4:29
0

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 */

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.