Hi @ericbourges
Thanks for writing in,
Do you want to redirect the users to a certain page after registration?
Please describe your requirement in detail?
Regards!
WPEverest Support Team.
Hi Sandip,
Thanks for the quick response
I have 2 options:
– On the page with the registration form, I would like the user to be redirected after registering on another page (for example their account page).
– On all the other pages, the registration form opens in a pop-up window and in this case I would like the user to stay on the page (typically to do an action requiring to be registered)
I hope I was clear, thank you for your help
Eric
Hi @ericbourges
Thanks for writing back,
In order to redirect the user’s to another page after registration, you can go to the form’s settings and in General Settings you can find the option to insert the Redirection URL after registration.
Could you please provide me the URL of the page where the registration form popups? I will check on this matter and get back to you.
Regards!
Yes, I know that we can define the redirect page in the settings.
The popup window with the form can be opened from multiple pages, what I would like is to be able to define a redirect after registration but only for the registration page (of which I know the ID and url)
In another thread in this support, I saw that you offered an add_action on user_registration_before_registration_form and an add_filter on user_registration_redirect_from_registration_page.
Maybe it could be useful for me?
Regards
Eric
Hi @ericbourges
Thanks for writing back,
Hook for redirection after registration:
apply_filters( 'user_registration_redirect_from_registration_page', $redirect_url, $current_user );
I hope this helps.
Regards!
Thanks to you!
Can you just explain to me quickly how to use it?
Hi @ericbourges
Thanks for writing back,
If you want the users to stay in same page after registration, please use the following code.
add_action( 'user_registration_before_registration_form', 'ur_set_register_redirect_url' );
function ur_set_register_redirect_url( $form_id ) {
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
set_transient( 'originalLoginRefererURL', $_SERVER['HTTP_REFERER'], 60 * 60 * 24 );
}
}
add_filter( 'user_registration_redirect_from_registration_page', 'ur_register_redirect_back', 10, 2 );
function ur_register_redirect_back( $redirect, $user ) {
if ( true === ( $redirect_url = get_transient( 'originalLoginRefererURL' ) ) ) {
delete_transient( 'originalLoginRefererURL' );
error_log( print_r( $redirect_url, true ) );
return $redirect_url;
}
return $redirect_url;
}
Regards!
Hi @ericbourges
Since you haven’t written us back for few days/weeks, you are going to mark this ticket as resolved.
Please let us know if you have any questions.
Regards!