Redirect to custom URL after registering from a page with registration form

I have this form in a page template

<form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
    <div class="formrow requiredRow"><label id="FullName-ariaLabel" for="txt_FullName">Full Name</label>
    <input class="required" id="txt_FullName" title="Full Name. This is a required field" type="text" name="first_name" /></div>

    <div class="formrow requiredRow"><label id="FullName-ariaLabel" for="txt_FullName">Email</label>
    <input class="required" id="user_email" title="Full Name. This is a required field" type="text" name="user_email" /></div>          

    <div class="formrow requiredRow"><label id="Password-ariaLabel" for="pwd_Password">Password</label>
    <input class="required" id="pwd_Password" title="Password. This is a required field" type="password" name="user_pass" /></div>

    <div class="row">
    <input class="" id="user_login" type="hidden" name="user_login"/>
    <?php do_action('register_form'); ?>
    <input type="submit" value="Submit form" /></div>

</form>

I need to redirect to a custom page so I have tried this filter from the question below. After registering from my custom page, I am not being redirected to /my-page but I have been being redirected to http://www.example.com/wp-login.php?checkemail=registered with the message Registration complete. Please check your e-mail.

function __my_registration_redirect(){
    return home_url( '/my-page' );
}
add_filter( 'registration_redirect', '__my_registration_redirect' );

https://wordpress.stackexchange.com/a/19698/10413

How can I redirect to a custom URL when registrations are posting from a page with a custom template?

4 Answers
4

Instead of using home_url, header(location) you can use wp_redirect()

function __my_registration_redirect(){
    wp_redirect( '/my-page' );
    exit;
}
add_filter( 'registration_redirect', '__my_registration_redirect' );

This might be helpfull

Leave a Comment