Title: Remove points when entry is deleted
Last modified: August 21, 2016

---

# Remove points when entry is deleted

 *  Resolved [Víctor](https://wordpress.org/support/users/njusted/)
 * (@njusted)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/remove-points-when-entry-is-deleted/)
 * Hi! I have a question … I activated the option that add X points when you add
   an entry, and that, works. The problem come when I delete the post, the users
   still have the same points. Any idea what can i do?.
 * Thanks 🙂
 * [http://wordpress.org/plugins/mycred/](http://wordpress.org/plugins/mycred/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * (@designbymerovingi)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/remove-points-when-entry-is-deleted/#post-4093333)
 * Right now myCRED does not delete points for posts that gets deleted but you can
   add this though your themes functions.php file:
 *     ```
       add_action( 'transition_post_status', 'remove_points_for_deleted_items', 10, 3 );
       function remove_points_for_deleted_items( $new_status, $old_status, $post )
       {
       	// Load myCRED
       	$mycred = mycred_get_settings();
   
       	// Make sure we only deduct points if the user has been awarded points
       	if ( $mycred->has_entry( 'publishing_content', $post->ID, $post->post_author ) ) {
       		// User has received points so we deduct
       		$mycred->add_creds(
       			'deleted_post', // reference id
       			$post->post_author, // the user id
       			0-1, // amount, negative value means deduction
       			'Point deduction for deleted post' // Log entry
       		);
       	}
       }
       ```
   
 *  Thread Starter [Víctor](https://wordpress.org/support/users/njusted/)
 * (@njusted)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/remove-points-when-entry-is-deleted/#post-4093343)
 * It works! Thank you ^^
 *  Thread Starter [Víctor](https://wordpress.org/support/users/njusted/)
 * (@njusted)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/remove-points-when-entry-is-deleted/#post-4093351)
 * Sorry for reply the post, but now, when I edit a post, also remove points (the
   same points when delete post).
 *  Plugin Author [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * (@designbymerovingi)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/remove-points-when-entry-is-deleted/#post-4093355)
 * Sorry I see I forgot to include the delete check:
 *     ```
       add_action( 'transition_post_status', 'remove_points_for_deleted_items', 10, 3 );
       function remove_points_for_deleted_items( $new_status, $old_status, $post )
       {
       	// Make sure we only do this when a posts new status is 'trash' (moved to trash)
       	if ( $new_status != 'trash' ) return;
       	// Load myCRED
       	$mycred = mycred_get_settings();
   
       	// Make sure we only deduct points if the user has been awarded points
       	if ( $mycred->has_entry( 'publishing_content', $post->ID, $post->post_author ) ) {
       		// User has received points so we deduct
       		$mycred->add_creds(
       			'deleted_post', // reference id
       			$post->post_author, // the user id
       			0-1, // amount, negative value means deduction
       			'Point deduction for deleted post' // Log entry
       		);
       	}
       }
       ```
   
 *  Thread Starter [Víctor](https://wordpress.org/support/users/njusted/)
 * (@njusted)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/remove-points-when-entry-is-deleted/#post-4093356)
 * Awesome!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Remove points when entry is deleted’ is closed to new replies.

 * ![](https://ps.w.org/mycred/assets/icon-128x128.gif?rev=3512531)
 * [Points Management System For Gamification, Ranks, Badges, and Loyalty Rewards Program - myCred](https://wordpress.org/plugins/mycred/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mycred/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mycred/)
 * [Active Topics](https://wordpress.org/support/plugin/mycred/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mycred/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mycred/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Víctor](https://wordpress.org/support/users/njusted/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/remove-points-when-entry-is-deleted/#post-4093356)
 * Status: resolved