• Resolved kolshix

    (@kolshix)


    I use ajax validation there is a (PHP) code with an error message
    I want to add there a limit counting

    how to add validation in code

    
    function auth_user_login($user_login, $password, $login)
    {
    	$info = array();
        $info['user_login'] = $user_login;
        $info['user_password'] = $password;
        $info['remember'] = true;
    	
    	$user_signon = wp_signon( $info, false );
        if ( is_wp_error($user_signon) ){
    // 
    // ?? Limit Login Attempts Reloaded how to put error records here ?check ? 
    //
    		echo json_encode(array('loggedin'=>false, 'message'=>__('Wrong username or password.')));
        } else {
    		wp_set_current_user($user_signon->ID); 
            echo json_encode(array('loggedin'=>true, 'message'=>__($login.' successful, redirecting...')));
        }
    	
    	die();
    }
    
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kolshix

    (@kolshix)

    I found a solution, but I do not know if it is correct. But it works

    
    function auth_user_login($user_login, $password, $login)
    {
    	$info = array();
        $info['user_login'] = $user_login;
        $info['user_password'] = $password;
        $info['remember'] = true;
    	
    	$user_signon = wp_signon( $info, false );
        if ( is_wp_error($user_signon) ){
    // START Limit Login Attempts
    require_once( LLA_PLUGIN_DIR . '/core/LimitLoginAttempts.php' );
    // =END= Limit Login Attempts
    		echo json_encode(array('loggedin'=>false, 'message'=>__('Wrong username or password.')));
        } else {
    		wp_set_current_user($user_signon->ID); 
            echo json_encode(array('loggedin'=>true, 'message'=>__($login.' successful, redirecting...')));
        }
    	
    	die();
    }
    
    
    Plugin Author WPChef

    (@wpchefgadget)

    Hi kolshix,

    You don’t have to add anything here. The plugin limits login attempts directly from wp_signon().

    You can find the error code/text here: $user_signon ($user_signon->get_error_code() and $user_signon->get_error_message());

    [ Signature deleted ]

    • This reply was modified 6 years, 3 months ago by Jan Dembowski.
    Thread Starter kolshix

    (@kolshix)

    Yes you are right! )) Thank you

    I did not fully consider the problem

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘LLA Reloaded + Ajax + php CHEK’ is closed to new replies.