Answer the question
In order to leave comments, you need to log in
How to remove the redirect when there is a data entry error when registering Wordpress?
I have code that redirects to my modal window:
function redirect_reg_page() {
$reg_page = home_url( '/#join_form' );
$page_viewed = basename($_SERVER['REQUEST_URI']);
if( $page_viewed == "wp-login.php?action=register" && $_SERVER['REQUEST_METHOD'] == 'GET') {
wp_redirect($reg_page);
exit;
}
}
add_action('init','redirect_reg_page');
<div class="popup">
<p>Регистрация</p>
<p>Пожалуйста заполните все поля</p>
<form name="registerform" action="http://mysite.ru/wp-login.php?action=register" method="post" novalidate="novalidate">
<div><p>
<label for="user_login">Имя пользователя<br>
<input id="firstname" type="text" name="user_login" value="" size="30"></label>
</p></div>
<div><p>
<label for="user_email">E-mail<br>
<input id="email" type="email" name="user_email" value="" size="30"></label>
</p></div>
<p id="reg_passmail">Пароль будет отправлен вам на e-mail.</p>
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Регистрация"></p>
</form>
<a class="close" href="#close"></a>
</div>
Answer the question
In order to leave comments, you need to log in
add_action('register_post', 'binda_register_fail_redirect', 99, 3);
function binda_register_fail_redirect( $sanitized_user_login, $user_email, $errors ){
//this line is copied from register_new_user function of wp-login.php
$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
//this if check is copied from register_new_user function of wp-login.php
if ( $errors->get_error_code() ){
//setup your custom URL for redirection
$redirect_url = get_bloginfo('url') . '/registrace';
//add error codes to custom redirection URL one by one
foreach ( $errors->errors as $e => $m ){
$redirect_url = add_query_arg( $e, '1', $redirect_url );
}
//add finally, redirect to your custom page with all errors in attributes
wp_redirect( $redirect_url );
exit;
}
}
similar situation:
wordpress.stackexchange.com/questions/21765/redire...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question