If you're looking to maintain the redirect_to url from the login to the registration and back to the login page, so the user can just enter their password once received by email, and still return to the original referrer this is the full solution.
function custom_register_url( $registration_url ) {
$redirect_to = $_GET["redirect_to"];
$eab_msg = $_GET["eab"];
if( $redirect_to != "" && $eab_msg != "" ) {
// change query name values to prevent default behaviour (redirect_to to uct_redirect)
$registration_url = sprintf( '<a href="%s&%s&%s">%s</a>', esc_url( wp_registration_url() ), "uct_redirect=" . urlencode($redirect_to), "uct_eab=" . urlencode($eab_msg), __( 'Register' ) );
}
return $registration_url;
}
add_filter( 'register', 'custom_register_url' );
function custom_registration_redirect($registration_redirect) {
$redirect_to = $_GET["uct_redirect"];
$eab_msg = $_GET["uct_eab"];
if( $redirect_to != "" && $eab_msg != "" ) {
// change query names back to original values (uct_redirect to redirect_to)
$registration_redirect = wp_login_url( $redirect_to ) . '&eab=' . $eab_msg;
}
return $registration_redirect;
}
add_filter( 'registration_redirect', 'custom_registration_redirect' );
Just drop it in functions.php. Hope this helps someone Cheers!