How to redirect a sucessful registration to a page template?

Each time I register I end up in the wp-login page (back-end):

enter image description here

Read More

Is there any way of redirecting the users who register to a page template (front-end)?

Related posts

Leave a Reply

4 comments

  1. You can use the filter registration_redirect to pass back your own URL, for example;

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

    Drop it in your functions.php or a plugin 🙂

  2. This is what i use

    <form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
    <input type="text" name="user_login" value="Username" id="user_login" class="input" />
    <input type="text" name="user_email" value="E-Mail" id="user_email" class="input"  />
    <?php do_action('register_form'); ?>
    <input type="submit" value="Register" id="register" />
    <input type="hidden" name="redirect_to" value="/success"/>
    <p class="statement">A password will be e-mailed to you.</p>
    </form>
    
  3. If like me, you use a plugin like ProfilePress to power/create your WordPress registration form, the following code will automatically log in and redirect registered users to a welcome page.

    add_action( 'pp_after_registration', 'pp_redirect_after_registration', 10, 3 );
    
    function pp_redirect_after_registration( $form_id, $user_data, $user_id ) {
    
        wp_set_auth_cookie( $user_id );
        wp_set_current_user( $user_id );
    
        $custom_page_url = 'http://example.com/welcome/';
    
        wp_redirect( $custom_page_url );
        exit;
    }
    

    Note: I use the free plugin (https://wordpress.org/support/plugin/ppress) version and the above code work both in free and the PRO version.

  4. I have developed a plugin for this issue. Also given below is the raw code for a redirect without any plugin.

    /**
     * Redirect users to custom URL based on their role after login
     **/
    function wp_woo_custom_redirect( $redirect, $user ) {
    
        // Get the first of all the roles assigned to the user
        $role = $user->roles[0];
        $dashboard = admin_url();
        $myaccount = get_permalink( wc_get_page_id( 'my-account' ) );
    
        if( $role == 'administrator' ) {
    
            //Redirect administrators to the dashboard
            $admin_redirect = get_option('admin_redirect');
            $redirect = $admin_redirect;
        } elseif ( $role == 'shop-manager' ) {
    
            //Redirect shop managers to the dashboard
            $shop_manager_redirect = get_option('shop_manager_redirect');
            $redirect = $shop_manager_redirect;
        } elseif ( $role == 'customer' || $role == 'subscriber' ) {
    
            //Redirect customers and subscribers to the "My Account" page
            $customer_redirect = get_option('customer_redirect');
            $redirect = $customer_redirect;
        } else {
    
            //Redirect any other role to the previous visited page or, if not available, to the home
            $redirect = wp_get_referer() ? wp_get_referer() : home_url();
        }
        return $redirect;
    }
    add_filter( 'woocommerce_login_redirect', 'wp_woo_custom_redirect', 10, 2 );
    

    If you feel comfortable working with plugin or without code? You can download and install my plugin “WP WooCommerce Redirect