Title: Reducing points when users delete their posts
Last modified: August 22, 2016

---

# Reducing points when users delete their posts

 *  Resolved [sara.mansouri](https://wordpress.org/support/users/saramansouri/)
 * (@saramansouri)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/reducing-points-when-users-delete-their-posts/)
 * Hi Gabriel,
 * I want to reduce points when users delete their posts. I have added the code 
   that you provided in the following topic to my theme’s functions.php but it still
   doesn’t reduce points.
    I have tried changing 0-1 in last 2 lines of code to -
   2 but it doesn’t work either. could you please guide me? (I am using updated 
   version of MyCred) Thank you Sara
 * [https://wordpress.org/support/topic/remove-points-when-entry-is-deleted?replies=6](https://wordpress.org/support/topic/remove-points-when-entry-is-deleted?replies=6)
 * 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 ); } }
 * [https://wordpress.org/plugins/mycred/](https://wordpress.org/plugins/mycred/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [sara.mansouri](https://wordpress.org/support/users/saramansouri/)
 * (@saramansouri)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/reducing-points-when-users-delete-their-posts/#post-5744533)
 * I have used the following code that you provided in the following link and it
   works. Thank you.
    I want to let users edit or delete their posts from front 
   end. There was some when I wanted to use WP frontent plugin as it tries to delete
   permanently instead of moving to trash. Now I use Frontier Post plugin and it
   works fine.
 * [http://mycred.me/support/forums/topic/deduct-points/](http://mycred.me/support/forums/topic/deduct-points/)
   
   add_action( ‘transition_post_status’, ‘fired_on_post_change_staus’, 10, 3 ); 
   function **fired_on_post_change_staus**( $new_status, $old_status, $post ) { 
   if ( $new_status == ‘trash’ ) { if ( ! function_exists( ‘mycred_add’ ) ) return;
 *  if ( isset( $post->post_author ) ) {
    mycred_add( ‘deleted_post’, $post->post_author,-
   10, ‘%plural% deduction for deleted post’ ); } } }

Viewing 1 replies (of 1 total)

The topic ‘Reducing points when users delete their posts’ 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/)

 * 1 reply
 * 1 participant
 * Last reply from: [sara.mansouri](https://wordpress.org/support/users/saramansouri/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/reducing-points-when-users-delete-their-posts/#post-5744533)
 * Status: resolved