Integrate with custom AJAX login page
-
Hi, I have a custom Ajax login function like:
if( !function_exists('lk_ajax_login') ): function lk_ajax_login(){ check_ajax_referer( 'security-lk-login', 'security' ); $email = $_POST['email']; $password = $_POST['password']; //Check for empty fields if(empty($email) || empty ($password)){ //create new error object and add errors to it. $error = new WP_Error(); if(empty($email)){ //No email $error->add('empty_username', __('<strong>ERROR</strong>: Email field is empty.')); } else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ //Invalid Email $error->add('invalid_username', __('<strong>ERROR</strong>: Email is invalid.')); } if(empty($password)){ //No password $error->add('empty_password', __('<strong>ERROR</strong>: Password field is empty.')); } } //Check if user exists in WordPress database $user = get_user_by('email', $email); //bad email if(!$user){ $error = new WP_Error(); $error->add('invalid', __('<strong>ERROR</strong>: Either the email or password you entered is invalid.')); HERE I WANT TO ADD AN OPTION TO ALERT PLUGIN THAT THIS WAS LOGIN ATTEMPT AND TO COUNT THIS IP AS A POTENTIAL HACKER ! } else{ //check password if(!wp_check_password($password, $user->user_pass, $user->ID)){ //bad password $error = new WP_Error(); $error->add('invalid', __('<strong>ERROR</strong>: Either the email or password you entered is invalid.')); HERE I WANT TO ADD AN OPTION TO ALERT PLUGIN THAT THIS WAS LOGIN ATTEMPT AND TO COUNT THIS IP AS A POTENTIAL HACKER ! } else{ //passed and do my stuff when login is OK } } wp_die(); }
So my question is… how to connect my login script with this plugin ?
- The topic ‘Integrate with custom AJAX login page’ is closed to new replies.