Save Gravity Forms Advanced Field to Custom Meta Field

Last month , it happen that I need to build something for a client using the Gravity Forms , it is my first time using Gravity Form this premium plugin, it is a very interesting plugin which help a lot if you need a front end submission form, I would like to share one of tips how you can use the advanced field mapping to the custom meta field of a post.

For example if you want to map a form field to a custom meta field for the post, just drag the Custom Field from the Post Fields section to your form and select from the drop down, which custom field it should map to, very easy.

gravity-form-save-custom-field-1gravity-form-save-custom-field-2

by now, when the user submit the form, the form value will auto save to that particular custom meta value, but what if you want to use the Gravity Forms Advanced Field ? some of the Gravity Forms Advanced Field allow you to save lots of time , for example the address field, you created all the fields in one go, no need to create each address field one by one.

Gravity Forms Advanced Field

How to map this Gravity Forms Advanced Field to your Custom Meta Field ? you need to write some code and put it under your functions.php , the action name should be gform_after_submission_<your form id> , the parameter $entry[‘29.3’] is map to 3rd sub field , for example if your Address field id is 29 , the 3rd field will be City, it follow the number order, you just need repeat the update_post_meta

Additional tips:

  • If you want to save the Gravity Forms Entry to custom post type, use this plugin
  • If you want to save Gravity Forms Advanced Field to ACF Plugins , use this gists , it just replace update_post_meta function with ACF function.

 

You may also like...