1. Home
  2. ReHub Theme
  3. Advanced tips and customizations
  4. How to turn post to draft based on negative voting

How to turn post to draft based on negative voting

Here is code snippet for this

add_action('rh_overall_post_likes_add', 'set_badge_hot_counter');
function set_badge_hot_counter(){
   $post_id = intval( $_POST['post_id'] );
   $hotcount = get_post_meta($post_id, 'post_hot_count', true);
   if($hotcount && $hotcount < 10){
       $my_post = array();
       $my_post['ID'] = $post_id; 
       $my_post['post_status'] = 'draft';
       wp_update_post( $my_post );
   }
}

You must place code in functions.php of child theme. Check how to customize theme