Does anyone know how to get access to user meta data on the wordpress backend? I'm trying to see if there is a "user_(linkedin, instagram, facebook, etc)_url". I'm working with a custom php file, and there is an arr called $data that is being created like this:
$fields = [
'headshotID' => 'medicus-headshot',
'firstname' => 'first_name',
'lastname' => 'last_name',
'title' => 'medicus-title',
'biography' => 'medicus-biography',
'address1' => 'medicus-address1',
'address2' => 'medicus-address2',
'city' => 'medicus-city',
'state' => 'medicus-state',
'zip' => 'medicus-zip',
'phone' => 'medicus-phone',
];
foreach ($doctors as $doctor) {
$data = [];
foreach ($fields as $key=>$val) {
$data[$key] = get_user_meta($doctor->ID, $val, true);
}
For the key-value pairs in $fields, it seems (I'm guessing) the "values" are the key names in the user metadata table, which contains the following per wordpress docs: ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status and display_name (https://developer.wordpress.org/plugins/users/working-with-user-metadata/)
I've logged into phpmyadmin and have looked at the wp_users and wp_metadata tables and I do not see any columns for social media url's.
Is this user metadata table the same place where the values in $fields are being stored? If yes, are there also values for the user's social media information? I'm trying to display the user's info for their social media, specifically the url to their profiles. Is there a "user_linkedin_url", or "user_instagram_url", or anything like that?
I came across this post, but it wasn't very helpful. Maybe I missed something.
In the user wp backend image I attached, you'll see info for the user. I'm trying to display the user's social media url, like their instagram url for instance. How can I do that?
UPDATE (mods and fellow more experienced devs, edit where you see fit. I feel sharing this info is helpful to beginner wordpress devs and should be shared with the community)
1 year update (yikes). To answer my own questions:
- Is this user metadata table the same place where the values in $fields are being stored?
YES
- If yes, are there also values for the user's social media information?
Yes, if there are meta_keys that specifically hold information about the user's social media information. In my case, there were actual meta_keys for 'instagram' and 'facebook'. Logging into PhpMyAdmin, I performed this query: SELECT * FROM wp_usermeta
WHERE meta_key
= "facebook", and sure enough, a bunch of results came up showing users with facebook info.
- Is there a "user_linkedin_url", or "user_instagram_url", or anything like that?
There can be, if you create custom fields and give them those meta_key names. However, in my particular case, those meta_keys didn't exist. The meta_keys were instead just called 'linkedin' and 'instagram', respectively.
get_user_meta(id, meta_key, true)
was what I needed. @Bikram answered it well.wp_usermeta
is the table with all user info.