![]() |
| ||||||||
|
|
#1 |
|
Old, tired and ugly coot
War Room Member
Join Date: May 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 1,112
Thanks: 103
Thanked 33 Times in 27 Posts
|
I want to extract a piece of data for the logged in user from the Wordpress database, so that I can use it as a variable in another script. The data is the value in a key:value pair in the meta_value field.
Retrieving data from the Wordpress database seems confusing as all get out to me. I saw the $wpdb function, but after that I get lost. Anyone here what can help with the SQL for that? I use MySQL on a Linux server. Many thanks in advance, Kirk |
|
Thought For The Day.
My thoughts are like lightning. One brilliant flash, and then they're gone. |
|
|
|
|
|
|
#2 |
|
SEO Expert Warrior
War Room Member
Join Date: Dec 2008
Location: United Kingdom / USA
Posts: 34
Thanks: 5
Thanked 24 Times in 5 Posts
|
Had the same problem and will be happy for someone to share info how its done
|
|
|
|
|
|
#3 |
|
HyperActive Warrior
War Room Member
Join Date: Dec 2002
Location: Mobile, AL , USA.
Posts: 273
Thanks: 65
Thanked 41 Times in 37 Posts
|
Did you read the information on this page:
Function Reference/wpdb Class WordPress Codex Spells it out for you pretty well. John |
|
|
|
|
|
#4 |
|
Warrior Member
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
|
I think you want to query data directly from wordpress database.
The table containing user information is wp_users. You can read schema from link gave by john_kennedy. After login and connect to wp database. I think you can use this SQL command. "select * from wp_users" |
|
|
|
|
|
#5 |
|
Web Developer, IT Support
War Room Member
Join Date: Dec 2008
Location: Birmingham, UK
Posts: 359
Thanks: 7
Thanked 50 Times in 45 Posts
|
Assuming you've stored the user meta data in the correct way (i.e. it's in the wp_usermeta table), you can just use:
PHP Code:
|
|
|
|
|
|
|
|
|
#6 |
|
Old, tired and ugly coot
War Room Member
Join Date: May 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 1,112
Thanks: 103
Thanked 33 Times in 27 Posts
|
Many thanks to all ... but it seems that old retired bean counters have mental blocks from all the numbers they read over the years ... meaning, I still have problems.
![]() I had previously tried reading the function reference for the wpdb class (which I called the $wpdb function in my original post), but it wasn't basic or simple enough for me. My understanding of code is limited to cut and paste. (That's what happens after thrity years as an accountant, you get stupidiated.) Based on Tim's (N7) line of code, I tried Code:
<?php = get_usermeta(userID, 'metakey'); echo . "n"; ?> edit: seems the $mydata and the \ before the n disappeared from the code block ... sorry. My user_id value is 1 My meta_key value is dr_extra_fields The meta_value field for that record contains ... Code:
s:203:"a:6:{s:10:"dr_address";s:11:"PO Box 1787";s:7:"dr_city";s:7:"Ellijay";
s:8:"dr_state";s:2:"GA";s:6:"dr_zip";s:5:"30540";s:8:"dr_phone";
s:14:"(706) 698-5475";s:10:"dr_bp_name";s:20:"Kirk Ward Accounting";}";
Any further ideas? Thanks in advance. Kirk |
|
Thought For The Day.
My thoughts are like lightning. One brilliant flash, and then they're gone. |
|
|
|
|
![]() |
|
| Tags |
| data, database, piece, wordpress |
| Thread Tools | |
|
|
![]() |