Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM › Update ACF fields on all product saves
- This topic has 2 replies, 2 voices, and was last updated 4 years, 8 months ago by garliclover23.
Viewing 2 reply threads
- AuthorPosts
- April 22, 2020 at 7:15 pm #121863garliclover23Participant
I’m trying to programatically update custom fields when products are modified.
I’m using ACF but I don’t need to.
I want to be sure to update them every time a product is modified – import, bulk, vendor, frontend, wp dashboard, etc.
I’ve got it to work on the WP dashboard but not wcfm.
Is there a hook I should use?
Very grateful for all assistance.
I’ve got:
add_action('save_post', 'my_acf_save_post',100,1); function my_acf_save_post( $post_id ) { update_field('_the_field_to_update', 'the text to put in');
- April 22, 2020 at 7:30 pm #121880Sarmistha ChakrabortyMember
Hello,
You can use this action,
add_action( 'after_wcfm_products_manage_meta_save', 'fn_custom_product_data_save',10,2 ); function fn_custom_product_data_save($new_product_id, $wcfm_products_manage_form_data) { /* you can find your custom field value $wcfm_products_manage_form_data*/ update_post_meta( $new_product_id, '_the_field_to_update', $wcfm_products_manage_form_data['product_custom_field'] ); } }
Thanks.
- April 24, 2020 at 8:41 am #122390garliclover23Participant
Thank you, super helpful.
- AuthorPosts
Viewing 2 reply threads
- You must be logged in to reply to this topic.