Redirecting a successful registration with Ninja Forms Front End Editor custom registration form

I’ve been digging into Ninja Forms and their Front End Editor add-on recently. Their default user registration form comes with a great set of options, including redirecting successful registrations to the referring page, but he same options are not available if you opt to use one of your own forms. Redirecting successful registrations to the…

Published in

I’ve been digging into Ninja Forms and their Front End Editor add-on recently. Their default user registration form comes with a great set of options, including redirecting successful registrations to the referring page, but he same options are not available if you opt to use one of your own forms.

Redirecting successful registrations to the referring page allows your audience to keep their place on the site and return to what they were doing before deciding to register.

Using your own form allows you to capture additional information with each registration which is stored as user meta fields which opens up a lot of possibilities for customising your site.

Add the following code to a site specific plugin to redirect successful registrations to the referring page.

add_action( 'ninja_forms_register_user', 'registration_do_redirect' );
function registration_do_redirect() {
    $redirect_url = $_REQUEST["_referrer"];
    wp_redirect( $redirect_url );
    exit;
}

The above code uses a hook available in Front End Editor which is triggered just after a new user is created and signed on. Front End Editor adds a hidden field with the URL of the referring page already, so this function simply grabs that value and uses a WordPress function to complete the redirection.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *