Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('transition_post_status', 'new_product_add', 10, 3);
- function new_product_add($new_status, $old_status, $post) {
- if(
- $old_status != 'publish'
- && $new_status == 'pending'
- && !empty($post->ID)
- && in_array( $post->post_type,
- array( 'product')
- )
- ) {
- $term = get_term_by('name', 'فروش پیج اینستاگرام', 'product_cat');
- wp_set_object_terms($post->ID, $term->term_id, 'product_cat', true);
- /******************************/
- $product = wc_get_product($post->ID);
- $product->set_description("something");
- $product->save();
- /******************************/
- }
- }
- wp_update_post( array('ID' => $post->ID, 'post_content' => "something"));
- Failed to load resource: the server responded with a status of 500 () (index):1
- add_action('transition_post_status', 'new_product_add', 10, 3);
- function new_product_add($new_status, $old_status, $post) {
- if(
- $old_status != 'publish'
- && $new_status == 'pending'
- && !empty($post->ID)
- && $post->post_type === 'product'
- ) {
- $term = get_term_by('name', 'فروش پیج اینستاگرام', 'product_cat');
- wp_set_object_terms($post->ID, $term->term_id, 'product_cat', true);
- // unhook this function so it doesn't loop infinitely
- remove_action( 'transition_post_status', 'new_product_add', 10 );
- wp_update_post( array('ID' => $post->ID, 'post_content' => "something"));
- // re-hook this function
- add_action( 'transition_post_status', 'new_product_add', 10, 3 );
- }
- }
- add_action('transition_post_status', 'new_product_add', 10, 3);
- function new_product_add($new_status, $old_status, $post) {
- if(
- $old_status != 'publish'
- && $new_status == 'pending'
- && !empty($post->ID)
- && $post->post_type === 'product'
- ) {
- $term = get_term_by('name', 'فروش پیج اینستاگرام', 'product_cat');
- wp_set_object_terms($post->ID, $term->term_id, 'product_cat', true);
- $product = wc_get_product($post->ID);
- // unhook this function so it doesn't loop infinitely
- remove_action( 'transition_post_status', 'new_product_add', 10 );
- $product->set_description("something");
- $product->save();
- // re-hook this function
- add_action( 'transition_post_status', 'new_product_add', 10, 3 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement