I want to add an action whenever the admin publishes a product, but the WP hook publish_post does not trigger then - even though a wc product is just another type of post.
I haven't found a woocommerce hook that triggers when a product is published.
Any thoughts?
I want to add an action whenever the admin publishes a product, but the WP hook publish_post does not trigger then - even though a wc product is just another type of post.
I haven't found a woocommerce hook that triggers when a product is published.
Any thoughts?
Share Improve this question asked Jan 29, 2020 at 22:33 Farmer MoFarmer Mo 111 bronze badge1 Answer
Reset to default 4The action hook publish_post
doesn't work for custom post types. You need to use the following format: publish_{$custom_post_type}
As you are using Woocommerce this post type is product so you want to use:
publish_product
.