名字以字母“Z”开头获取用户 [英] Get the users by first name start with letter "Z"

查看:127
本文介绍了名字以字母“Z”开头获取用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须得到所有名字以字母Z开头的用户。我通过使用get_users()函数获取用户信息。我如何使用参数查询来获得第一个字母以Z开头的用户?

I have to get all the users whose first name starts with the letter "Z". I get the user information by using the get_users() function. How can i use the argument query to get the users whose first name letter starts with "Z"?

我使用下面的函数显示了以 V,W,X,Y,但不是Z

I used the function below that show me the names that starts with "V", "W", "X", "Y", but not "Z"

$args = array(
            'role' => 'subscriber',
            'meta_query' => array(
                array(
                    'key' => 'first_name',
                    'value' => array( 'V', 'Z'),
                    'compare' => 'BETWEEN'
                )
            )
        );
        $users= get_users($args);


推荐答案

使用大于或等于运算符<$ meta_value 返回结果,其中 first_name 开头于> =

Use the "greater than or equals" operator >= on the meta_value to return results where first_name starts with "V" through "Z", inclusive.

$args = array(
    'role' => 'subscriber',
    'meta_query' => array(
        array(
            'key' => 'first_name',
            'value' => 'V',
            'compare' => '>='
        )
    )
);
$users = get_users( $args );

这篇关于名字以字母“Z”开头获取用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆