Update ACF fields on all product saves

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM Update ACF fields on all product saves

Tagged: , ,

Viewing 2 reply threads
  • Author
    Posts
    • #121863
      garliclover23
      Participant

      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');
      
      
    • #121880

      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.

    • #122390
      garliclover23
      Participant

      Thank you, super helpful.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.