Title: Условия авторизации на измененный wp-login
Last modified: 31.10.2017

---

# Условия авторизации на измененный wp-login

 *  [andytom](https://ru.wordpress.org/support/users/andytom/)
 * (@andytom)
 * [8 лет, 11 месяцев назад](https://ru.wordpress.org/support/topic/%d1%83%d1%81%d0%bb%d0%be%d0%b2%d0%b8%d1%8f-%d0%b0%d0%b2%d1%82%d0%be%d1%80%d0%b8%d0%b7%d0%b0%d1%86%d0%b8%d0%b8-%d0%bd%d0%b0-%d0%b8%d0%b7%d0%bc%d0%b5%d0%bd%d0%b5%d0%bd%d0%bd%d1%8b%d0%b9-wp-login/)
 * Изменил страницу входа на auth.php
 *     ```
       add_action( 'wp_login_failed', 'pu_login_failed' ); // hook failed login
       function pu_login_failed( $user ) {
       	  $users = get_user_by('login', $user);
       	  $user_id = $users->ID;
       	  $user_blacklist = get_user_meta($user_id, 'blacklist', true);
       	 // check what page the login attempt is coming from
       	 $referrer = $_SERVER['HTTP_REFERER'];
       	 // check that were not on the default login page
       	 if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') && $user!=null ) {
       		  // make sure we don't already have a failed login attempt
       		  if ( $user_blacklist == '1' ) {
       				 wp_redirect( $referrer . '/auth/?errors=2');
       		 } else
       		  if ( !strstr($referrer, '/auth/' ) || !strstr($referrer, '/auth/?errors=1' )) {
       			   // Redirect to the login page and append a querystring of login failed
       		  wp_redirect( $referrer . '/auth/?errors=1');
       		 } else {
       			   wp_redirect( $referrer );
       		 }
       		 exit;
       	 }
       }
   
       add_action( 'authenticate', 'pu_blank_login');
   
       function pu_blank_login( $user ){
       	$users = get_user_by('login', $user);
       	  $user_id = $users->ID;
       	  $user_blacklist = get_user_meta($user_id, 'blacklist', true);
       	// check what page the login attempt is coming from
       	$referrer = $_SERVER['HTTP_REFERER'];
   
       	$error = false;
   
       	if($_POST['log'] == '' || $_POST['pwd'] == '')
       	{
       		$error = true;
       	}
   
       	// check that were not on the default login page
       	if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') && $error ) {
   
       	  if($user_blacklist == '1') {
       		  wp_redirect( $referrer . '/auth/?errors=2' );
       		} else if ( !strstr($referrer, '/auth/') || !strstr($referrer, '/auth/?errors=1')) {
       			// Redirect to the login page and append a querystring of login failed
       			wp_redirect( $referrer . '/auth/?errors=1' );
       		} else  {
       		  wp_redirect( $referrer );
       		}
   
       	exit;
   
       	}
       }
       ```
   
 * Но не обрабатывается проверка
    `if ( $user_blacklist == '1' ) {` Может я что 
   не там написал?

Просмотр 1 ответа (всего 1)

 *  Модератор [Юрій](https://ru.wordpress.org/support/users/yube/)
 * (@yube)
 * [8 лет, 11 месяцев назад](https://ru.wordpress.org/support/topic/%d1%83%d1%81%d0%bb%d0%be%d0%b2%d0%b8%d1%8f-%d0%b0%d0%b2%d1%82%d0%be%d1%80%d0%b8%d0%b7%d0%b0%d1%86%d0%b8%d0%b8-%d0%bd%d0%b0-%d0%b8%d0%b7%d0%bc%d0%b5%d0%bd%d0%b5%d0%bd%d0%bd%d1%8b%d0%b9-wp-login/#post-263400)
 * Смотрю [https://codex.wordpress.org/Plugin_API/Filter_Reference/authenticate](https://codex.wordpress.org/Plugin_API/Filter_Reference/authenticate)
   
   и вижу
 * > Parameters
   > $user
   >  (null or WP_User or WP_Error) (required) null indicates no process has
   > authenticated the user yet. A WP_Error object indicates another process has
   > failed the authentication. A WP_User object indicates another process has authenticated
   > the user.
   >  Default: None
   > $username
   >  (string) (required) The user’s username.
   >  Default: None
   > $password
   >  (string) (optional) The user’s password (plaintext — NOT encrypted).
   >  Default: None
 * А у Вас первый параметр используется как строка с username.
 *     ```
       add_action( 'authenticate', 'pu_blank_login');
       function pu_blank_login( $user ){
       	$users = get_user_by('login', $user);
       ```
   
 * Возможно, в этом причина.

Просмотр 1 ответа (всего 1)

 Тема «Условия авторизации на измененный wp-login» закрыта для новых ответов.

## Метки

 * [hook](https://ru.wordpress.org/support/topic-tag/hook/)
 * [wp_login](https://ru.wordpress.org/support/topic-tag/wp_login/)

 * Форум: [Проблемы и решения](https://ru.wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 ответ
 * 2 участника
 * Последний ответ: [Юрій](https://ru.wordpress.org/support/users/yube/)
 * Последняя активность: [8 лет, 11 месяцев назад](https://ru.wordpress.org/support/topic/%d1%83%d1%81%d0%bb%d0%be%d0%b2%d0%b8%d1%8f-%d0%b0%d0%b2%d1%82%d0%be%d1%80%d0%b8%d0%b7%d0%b0%d1%86%d0%b8%d0%b8-%d0%bd%d0%b0-%d0%b8%d0%b7%d0%bc%d0%b5%d0%bd%d0%b5%d0%bd%d0%bd%d1%8b%d0%b9-wp-login/#post-263400)
 * Статус: нерешённая

## Темы

### Самые популярные темы

### Темы без ответов

### Без вопроса

### Решённые

### Нерешённые

### Все темы
