Joey Nizuk

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: UsersWP Default Value for Gravity Forms #1109

    Joey Nizuk
    Free User
    Post count: 7

    cool thanks guys!

    in reply to: UsersWP Default Value for Gravity Forms #1105

    Joey Nizuk
    Free User
    Post count: 7
    This reply has been marked as private.
    in reply to: UsersWP Default Value for Gravity Forms #1091

    Joey Nizuk
    Free User
    Post count: 7
    This reply has been marked as private.
    in reply to: UsersWP Default Value for Gravity Forms #1089

    Joey Nizuk
    Free User
    Post count: 7
    This reply has been marked as private.
    in reply to: UsersWP Default Value for Gravity Forms #1040

    Joey Nizuk
    Free User
    Post count: 7

    Hey Stiofan,

    Thanks for the reply. I did some more digging on my end and I also reached out to Gravity Forms to see what they would recommend and this is what they told me:

    If you need to pull from another database table, you won’t be able to use the Gravity Forms usermeta merge tags. You can use this filter to pull data from anywhere to populate fields in your form (it’s not specific to UserWP):

    https://docs.gravityforms.com/gform_field_value_parameter_name/

    So went ahead and tried to set that up, but I don’t know how to call the UserWP database tables for the uwp_usermeta.

    This is what I’ve tried so far: got conformation from Gravity forms that you can not use merge tags or the default values unless its for wordpress or gravity forms user data, but you can use parameters. So using the help article Gravity forms sent me I setup my parameters for my data (see screen shot) and added the following filter which returns a value from the database. This isn’t working and I’m not sure how I would go about pulling the upw_usermeta data from the database of current logged in user.

    
    
    // define the fields we'll be populating
    $fields = array('uwp_account_company', 'uwp_account_phone');
     
    // loop through fields and add the Gravity Forms filters
    foreach($fields as $field)
      add_filter('gform_field_value_'.$field, 'my_populate_field');
     
    
    // the callback that gets called to populate each field
    function my_populate_field($value){
      // we have to wrestle the field name out of the filter name,
      // since GF doesn't pass it to us
      $filter = current_filter();
      if(!$filter) return '';
      $field = str_replace('gform_field_value_', '', $filter);
      if(!$field) return '';
     
      // get the current logged in user object
      $user = wp_get_current_user();
     
      // We'll just return the user_meta value for the key we're given.
      // In most cases, we'd want to do some checks and/or apply some special
      // case logic before returning.
      return get_user_meta($user->ID, $field, true);
    }

    What are your thoughts?

Viewing 5 posts - 1 through 5 (of 5 total)