plugins – save_post_product action not firing


Im trying to save some meta values when I save a “product” post type. However my save_post action does not seem to be firing. Am I calling it wrong? The code within the class below shows the meta boxes in the admin fine but its just not calling the save.

 * Called from main plugin file
function knp_load_first() {

    new KnpvAdminProductMeta();

add_action('plugins_loaded', 'knp_load_first');

 * Output meta boxes and save meta values
class KnpvAdminProductMeta {

    function __construct(){

        //Save the meta values
        add_meta_box('knpv_submission_fields', 'Editable Submission Fields', array($this, 'knpv_submission_fields'), 'product', 'normal', 'default');
        add_action( 'save_post', [$this, 'knpv_save_meta_fields'], 10, 3 );


    public function knpv_save_meta_fields(){

        //For tesitng
        //This should kill the script and output the posted values
        //It doesnt!

        //Update the post meta
        update_post_meta($post_id, 'submissiondata', $_POST['submissiondata']);
        update_post_meta($post_id, 'included-with', $_POST['included-with'] );



Alex Knopp 1 year 2022-02-02T08:56:48-05:00 0 Answers 0 views 0

Leave an answer