从Wordpress用户元数据表中获取数据

时间:2022-09-15 16:38:48

I've to fetch user data from the usermeta table in wordpress database.fields of the usermeta table are

我必须从wordpress数据库中的usermeta表中获取用户数据。usermeta表的字段是

umeta_id
user_id
meta_key
meta_value

and sm=ome of the meta keys are first_name , last_name I want to retrieve data from the table based on this meta_key. I am getting data from the user main table using the query given below

而且,meta键的sm是first_name, last_name,我想要根据这个meta_key从表中检索数据。我使用下面给出的查询从用户主表获取数据。

$args  =  array(
    'blog_id'      => $GLOBALS['blog_id'],
    'role'         => '',
    'meta_key'     => '',
    'meta_value'   => '',
    'meta_compare' => '',
    'meta_query'   => array(),
    'include'      => array(),
    'exclude'      => array(),
    'orderby'      => 'ID',
    'order'        => 'ASC',
    'offset'       => '',
    'search'       => '',
    'number'       => '',
    'count_total'  => false,
    'fields'       => 'all',
    'who'          => ''
 ); 
// Create the WP_User_Query object
$wp_user_query = new WP_User_Query($args);

what to write if i need the first_name of the user with user id 1

如果我需要用户id为1的first_name,该写什么

please help me some one

请帮我拿一个

1 个解决方案

#1


2  

Have you tried to use Wordpress get_user_meta() function ?

你试过使用Wordpress get_user_meta()函数吗?

#1


2  

Have you tried to use Wordpress get_user_meta() function ?

你试过使用Wordpress get_user_meta()函数吗?