hook when a new Custom Post type is published

Question

i have a special situation that i want.
I want to make an update an option when we publish a new custom post type, everything works fine, but I want to add a condition on a meta field :

add_action( 'publish_my_product', array ( $this , 'product_create_success' ), 10, 2 );

And the function :

public function product_create_success( $ID, $post ) {
    $display_mainmenu = get_post_meta( $ID ,'_display_mainmenu');

    if( $display_mainmenu[0] == "yes" ){
        // Here Update the option .....
    }
    
}

The issue that the $display_mainmenu is not defined .

My question: is this the right hook where I can catch the value of the meta post?

0
Younes.D 2 months 0 Answers 13 views 0

Leave an answer