How to verify username & password in WP custom Login
first, we see wp_authenticate wp function for a moment,
wp_authenticate ( $username, $password )
Parameters: |
|
Returns: |
|
Defined at: |
Similar Functions: authenticate, wp_authenticate_cookie, authentication,use_authentication, authentication_header
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";
}
?>
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";
}
?>
0 Comments