Answer the question
In order to leave comments, you need to log in
Why is there a cookie error on wordpres?
Good afternoon, the site has implemented authorization through this form
<form method="POST" class="callback" name="loginform" id="loginform" action="<?php bloginfo('url') ?>/wp-login.php">
<label for="user_login">
<span class="placeholder">Логин</span>
<input type="text" name="log" id="user_login" autocomplete="off">
</label>
<label for="user_pass">
<span class="placeholder">Пароль</span>
<input type="password" name="pwd" id="user_pass" autocomplete="off">
</label>
<div class="button_wrapper">
<button name="wp-submit">Отправить</button>
</div>
<input type="hidden" name="redirect_to" value="https://site.ru">
<input type="hidden" name="testcookie" value="1">
</form>
function custom_login_page() {
$new_login_page_url = home_url( '/enter/' ); // new login page
global $pagenow;
if( $pagenow == 'wp-login.php' && $_SERVER['REQUEST_METHOD'] == 'GET' OR $pagenow == '/wp-admin/' ) {
wp_redirect($new_login_page_url);
exit;
}
}
if( !is_user_logged_in() OR !current_user_can('administrator') ){
add_action('init','custom_login_page');
}
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url( '/enter/' ) );
exit;
}
}
Answer the question
In order to leave comments, you need to log in
Fixed by submitting the form via ajax, but such a crutch, just awful...
Still waiting for advice on solving this problem.
My crutch
$('#loginform').submit(function(event) {
event.preventDefault();
var url = $(this).attr('action');
var logindata = $(this).serialize();
$.ajax({
url: url,
type: 'POST',
data: logindata,
})
.done(function() {
var url = $('#loginform').attr('action');
var logindata = $('#loginform').serialize();
$.ajax({
url: url,
type: 'POST',
data: logindata,
})
.done(function() {
window.location.href = 'https://site.ru/enter';
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question