Joey Nizuk
Forum Replies Created
-
AuthorPosts
-
cool thanks guys!
This reply has been marked as private.This reply has been marked as private.This reply has been marked as private.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?
-
AuthorPosts