i building website using woocommerce.by default username customer username.i want provide users feature login through phone number also. how can that? please help!
this possible. think not idea.. imagine 2 users shares same number.
but if can manage make phone number unique, can try woocommerce login form.
add_filter('woocommerce_login_credentials','woocommerce_login_credentials', 10, 1); function woocommerce_login_credentials($creds){ $username = trim( $_post['username'] ); if (is_numeric($username)){ // assumes numeric allowed. can own logic here. $user = get_users(array( 'meta_query' => array( array( 'key' => 'billing_phone', 'value' => $username, 'compare' => 'like', ), ) )); $creds['user_login'] = $user[0]->data->user_login; } return $creds; }
this code using billing phone number. if phone number belongs lot of users, first user query gets used. code is, gets user_login
of user using given phone number. use username logged in. can still use username/email login code.
this answer demonstrate can done. won't advice doing so.
Comments
Post a Comment