Hi @alanp57,
Apologies for my understanding.
Please copy and paste the following code and let be know if it works or not.
add_action( 'user_registration_before_customer_login_form', 'ur_set_login_redirect_url' );
function ur_set_login_redirect_url() {
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
set_transient( 'originalLoginRefererURL', $_SERVER['HTTP_REFERER'], 60*60*24 );
}
}
add_filter( 'user_registration_login_redirect', 'ur_login_redirect_back', 10, 2 );
function ur_login_redirect_back( $redirect, $user ) {
if ( true === ( $redirect_url = get_transient( 'originalLoginRefererURL' ) ) ) {
delete_transient( 'originalLoginRefererURL' );
return $redirect_url;
}
return $redirect_url;
}
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;
}
I hope this helps.
Regards!