Hi @sunnyschafieh,
You can do that using a piece of code. Please paste the following code in your active theme’s functions.php file at the end and it will do the trick.
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' );
return $redirect_url;
}
return $redirect_url;
}
Let me know if it helps or not and I will get back to you.
Regards!