Last active
August 29, 2015 14:23
-
-
Save thinkstylestudio/11be7dcc1f53e954d750 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add a Gravity forms form to product upon database save. | |
* | |
* Requires Gravity Forms and WooCommerce - Gravity Forms Product Add-Ons. | |
* | |
* Search for '_gravity_form_data' in wp_postmeta and set $raw_form_data to the serialized string. | |
* | |
* @return void | |
**/ | |
function mb_woo_product_insert_form($product_ID) { | |
$raw_form_data = ''; // Add serialized form data from MySQL here | |
$form_data = unserialize($raw_form_data); | |
$meta_key = '_gravity_form_data'; | |
$existing_meta = get_post_meta($product_ID, $meta_key, $single = true); | |
if ( strlen($existing_meta) > 0 ) return; | |
update_post_meta($product_ID, $meta_key, $form_data); | |
} | |
add_filter('save_post', 'mb_woo_product_insert_form'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment