Answer the question
In order to leave comments, you need to log in
How to remove a redirect when there is a data entry error while logging in to a Wordpress account?
I have code that redirects to my modal window:
function redirect_login_page() {
$login_page = home_url( '/#login_form' );
$page_viewed = basename($_SERVER['REQUEST_URI']);
if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
wp_redirect($login_page);
exit;
}
}
add_action('init','redirect_login_page');
<div class="popup">
<p>Добро пожаловать!</p>
<?php /* Панель входа на сайт */
global $user_ID, $user_identity;
get_currentuserinfo();
if (!$user_ID): ?>
<form name="loginform" action="<?php echo get_settings('siteurl'); ?>/wp-login.php" method="post">
<div><p>Логин<br /><input type="text" id="login" name="log" value="" size="30" /></p></div>
<div><p>Пароль<br /> <input type="password" id="password" name="pwd" value="" size="30" /></p></div>
<input type="hidden" name="rememberme" value="forever" />
<input type="submit" name="submit" value="Войти »" />
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
</form>
<?php else: ?>
Добро пожаловать, <?php echo $user_identity; ?>
<a href="<?php echo wp_logout_url( get_permalink() ); ?>">Выйти</a>
<?php endif; ?>
<a class="close" href="#close"></a>
</div>
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;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question