简体   繁体   中英

How can I access database from a specific plugin in Wordpress?

I have a plugin in wordpress which allows users to register on my website. I want to access their profile data (like the username or the profile image) the way I do with current_user->user_login but I can't find the correspondent database for that plugin. Is there a way to access the information the users store on their profile? I am a beginner so sorry in advance for any stupid question.

You're not looking for a plugin, but for a function. The function you should use for retrieving user meta (the correct name for what you call profile data) is get_user_meta();

An example:

// Get the user id
$user_id = get_current_user_id();

// Get the user meta, in this example 'description'
$user_description = get_user_meta( $user_id, 'description', true );

// Echo the description
echo $user_description;

Look here for more information on how to use get_user_meta();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM