Wordpress User Authentication | Wordpress User Login Authentication


How to verify username & password in WP custom Login

first, we see wp_authenticate wp function for a moment,

wp_authenticate ( $username, $password )
Parameters:
  • string $username User's username
  • string $password User's password
Returns:
  • WP_Error|WP_User WP_User object if login successful, otherwise WP_Error object.
Defined at:


Now, look at following code that help you authenticate User in Wordpress with help of wp_authenticate function
i.e :
<?php
session_start();
include('./../../../../wp-config.php');
error_reporting(0);
 if(isset($_POST['uname']) && $_POST['uname'] !='')
{
  $table=$wpdb->prefix . 'users';
  $user = wp_authenticate($_POST['uname'], $_POST['pwd']);
   if ($user->ID !='')
  {
    $_SESSION['user_id']=$user->ID;
    $_SESSION['user_name']=$user->display_name;
    echo "yes";
  }
  else
 {
   echo "no";
 }
}
else
{
  echo "no";
}
?>

Post a Comment

0 Comments