Getting an ARRAY of user Meta info and iphorm_element_value_?

Home Forums Quform WordPress Getting an ARRAY of user Meta info and iphorm_element_value_?

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #14542
    Joe Dostie
    Participant

    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 user

    echo '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,
    Joe

    #14545
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #14551
    Joe Dostie
    Participant

    I 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!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy