Home › Forums › Quform WordPress › Getting an ARRAY of user Meta info and iphorm_element_value_?
- This topic has 2 replies, 2 voices, and was last updated 9 years, 1 month ago by Joe Dostie.
- AuthorPosts
- March 11, 2015 at 8:45 pm #14542Joe DostieParticipant
Hello Support,
I have a two part question, I was hoping to get a hand with a function I am trying to build.
My goal is as follows:
I am using Quform to collect form info and put that info into the wp_usermeta table.
I have all the data flowing in with no problem and populating properly.My goal is to retrieve the data and set default values for the Quform when a registered user is logged in (I will prepopulate the form with some values pulled from the meta table).
So far I have most of the data populating and I am able to grab all the info but not exactly like I need to.
This is the code that is running and almost working
function get_meta()
global $array_of_data;$array_of_fields = array //Set the fields to retreive
(
'addr2',
'city',
'thestate'
);if (is_user_logged_in()) //See if user is logged in
{
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID; //Get the user ID
}{
$array_of_data = array();
foreach ( $array_of_fields as $each_field ) //set each field to parse through{
$array_of_data[ $field ] = get_user_meta( $user_id, $each_field, true ); //parse each field above for user
foreach ( $array_of_data as $each_field => $val ) //get each field above for userecho 'Each Field = ' . $each_field. ' and Each Value = '.$val.'<br />'; // <- This is the problem area
}}
add_filter('iphorm_element_value_'.$each_field'.', 'get_meta');
The $val (meta information) shows up with no problem, but I can not seem to associate each field (meta_key) I want with its value
The reason I am do it this way (and here is the second part of the question) is because I want use the hook
iphorm_element_value_$each_field. The second question is can you use the hook like that?I will continue to work on this but if you have any insight to either question I would be grateful.
The reason behind this code is related to https://support.themecatcher.net/forums/topic/adding-wp-user-name-and-user-last-name-to-the-database#post-3903
What I am trying to NOT do is write a function for each element on the form (I have 75).
Kind Regards,
JoeMarch 12, 2015 at 10:24 am #14545AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 12, 2015 at 2:17 pm #14551Joe DostieParticipantI cant thank you enough again Ally!
Your support and code are simply outstanding.
For some reason I am having the toughest time getting my head around these arrays but your code is definitely helping to clarify!
Thanks!
- AuthorPosts
- You must be logged in to reply to this topic.