我使用自定義wordpress代碼製作登錄表單,我堅持讓用戶可以通過電子郵件或用戶名登錄。 他們仍然只能使用用戶名和驗證過程中,我與WordPress功能的幫助下做wordpress使用用戶名或電子郵件登錄頁面
$user_verify = wp_signon($login_data, false);
請讓我知道我可以讓用戶使用任何電子郵件的用戶名登錄的。 謝謝。
我使用此代碼僅使用用戶名登錄。我怎樣才能改變它的電子郵件和用戶名登錄英寸
$username = $wpdb->escape($_REQUEST['username']);
$password = $wpdb->escape($_REQUEST['password']);
if ($username && $password) {
$login_data = array();
$login_data['user_login'] = $username;
$login_data['user_password'] = $password;
$user_verify = wp_signon($login_data, false);
$user_check = $user_verify->user_id;
if(!empty($user_verify->id))
{
do_action('wp_login', $user_verify->user_login, $user_verify);
wp_set_current_user($user_verify->ID);
wp_set_auth_cookie($user_verify->ID);
$r2 = get_current_user_id();
$registerd = get_user_meta($r2, 'package', true);
global $current_user;
$user_id=$current_user->data->ID;
$paid_tag_list=get_user_meta($user_id,'tags','');
$used_tag_list=get_user_meta($user_id,'tags','');
$company_name=get_user_meta($user_id,'company_name','');
$used_tag=explode(',',$used_tag_list[0]);
$used_tags=explode(',',$used_tag_list[0]);
if($paid_tag_list[0])
$paid_tag=explode(',',$paid_tag_list[0]);
else
$paid_tag=array();;
$paid_list=array_unique(array_filter(array_merge($paid_tag,$used_tags)));
foreach ($paid_list as $c){
$paid_l[]=str_replace(' ','',$c);
}
$directs=$wide->Getdirect();
foreach($directs as $key=>$value)
{
if($value==$info_post['desired_direction'][0])
{
$direct[]=$value ;
}
else
{
$direct[]=$value;
}
}
$states=array('USA'=>array(
'ALABAMA',
'Aguascalientes',
'Morelos',
'Tlaxcala',
)
);
$array = array("status" => "success", "message" => "user login","cars"=>$paid_l,"company"=>$company_name,"states"=>$states,"direction"=>$direct);
echo json_encode($array);
} else {
$array = array("status" => "fail", "message" => "Enter Correct Log-in info");
echo json_encode($array);
}
}else {
$array = array("status" => "fail", "message" => "something missing");
echo json_encode($array);
}
'如果($ user = get_user_by_email($ username)'這行缺少一個「)」這一切都在網絡上是一樣的。 ...它應該像下面一樣....'if($ user = get_user_by_email($ username))' –
謝謝:) Shahid Rafiq –