I'm using url like «wp-login.php?action=register&role=patient» and «register_form» hook for add extra inputs form which depends on urls like this:
add_action('register_form','add_extra_role_fields'); function add_extra_role_fields() { if (isset($_GET['role'])) { $user_type = $_GET['role']; } if (isset($user_type) && $user_type == "patient") [...] if (isset($user_type) && $user_type == "doctor") [...] Problem: Wordpress redirects user after form validation with error to http://example.com/wp-login.php?action=register instead of http://example.com/wp-login.php?action=register&role=patient and all logic is broken.
Question: Can wordpress redirect user to previos url «?action=register&role=doctor» (not default «?action=register») ?
Solution: Thank you Jan Fabry :).
if ( isset($_REQUEST['role']) && ( ($_REQUEST['role'] == 'patient') OR ($_REQUEST['role'] == 'doctor') ) ) { add_filter( 'site_url', 'doctor_site_url', 10, 4 ); function doctor_site_url( $url, $path, $scheme, $blog_id ) { if ( 'login_post' == $scheme ) { $url .= '&role='.$_REQUEST['role']; } return $url; } }