有一个:
<?php //...................
$user = get_user_by( 'email', 'user@example.com' );
echo $user->ID; /* User id */
?>
但是,在wp_users
表上工作。
user_login,user_email,user_nicename
我需要工作特殊的元键和值。
USER_PHONE
截图:
谢谢大家。
答案 0 :(得分:2)
/* delete login on user_login
if ( ! empty( $username ) )
$user = get_user_by( 'login', $username );
if ( isset( $user->user_login, $user ) )
$username = $user->user_email;
*/
/* add login with user_phone (in wp_user_meta) */
if ( ! empty( $username ) )
$user = reset( get_users(
array(
'meta_key' => 'user_phone',
'meta_value' => $username,
'number' => 1,
'count_total' => false
) ) );
if ( isset( $user->user_login, $user ) )
$username = $user->user_email;
/* /end/ add PHONE */
/* Add user login with user_email (in wp_users) */
$user = get_user_by('email', $username);
干得好:):