Problem triggering an action when product is published
-
Hello,
I’m trying to trigger an action when a product is published, but it doesn’t work, here is my code:add_action( 'transition_post_status', 'my_call_back_function', 10, 3 ); function my_call_back_function( $new_status, $old_status, $post ) { if ( 'product' !== $post->post_type || 'publish' !== $new_status || 'publish' === $old_status ) { return; } file_put_contents( 'file.txt', 'Product published', FILE_APPEND ); }
here I’m trying to create a file and put some text in it. but as I said, the file isn’t created. I’m using wordpress 5.8.1 and Woocommerce 5.8.0. What is the problem and how to solve it? Your help would be greatly appreciated.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Problem triggering an action when product is published’ is closed to new replies.