'_adev_otp_phone', 'meta_value' => $phone, 'number' => 1, 'count_total'=> false, ) ); if ( ! empty( $users ) && $users[0] instanceof \WP_User ) { return $users[0]; } // Fallback: WooCommerce billing_phone. $users = get_users( array( 'meta_key' => 'billing_phone', 'meta_value' => $phone, 'number' => 1, 'count_total'=> false, ) ); if ( ! empty( $users ) && $users[0] instanceof \WP_User ) { update_user_meta( $users[0]->ID, '_adev_otp_phone', $phone ); return $users[0]; } return null; } /** * Save phone on user. * * @param int $user_id User ID. * @param string $phone Normalized phone. */ public static function save_for_user( int $user_id, string $phone ): void { $phone = self::normalize( $phone ); if ( ! $phone || $user_id <= 0 ) { return; } update_user_meta( $user_id, '_adev_otp_phone', $phone ); update_user_meta( $user_id, 'billing_phone', $phone ); } /** * Check blacklist (comma/newline separated). * * @param string $phone Normalized phone. */ public static function is_blacklisted( string $phone ): bool { $list = (string) \Adev_OTP\Plugin::get_setting( 'phone_blacklist', '' ); if ( '' === trim( $list ) ) { return false; } $parts = preg_split( '/[\s,;]+/', $list ); if ( ! is_array( $parts ) ) { return false; } foreach ( $parts as $part ) { $n = self::normalize( $part ); if ( $n && $n === $phone ) { return true; } } return false; } }