Title: Notification on Trashed Post
Last modified: May 22, 2017

---

# Notification on Trashed Post

 *  Resolved [imagefact](https://wordpress.org/support/users/imagefact/)
 * (@imagefact)
 * [9 years ago](https://wordpress.org/support/topic/notification-on-trashed-post/)
 * Hi,
 * THANK YOU FOR THE PLUGIN!
 * Is there a way I can hook so that user DON’T receive a notification when their
   authored posts are trashed.
 * In this case the reason being that once posts are old, we want to remove them
   from our system. But we also don’t want to upset people by flagging them that
   their posts are being thrown out! : )
 * As long as we’re at it. If you have a list of hooks for similar functions, it
   would be good to know them for other situations that we’re setting up.

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

 *  [PressShack](https://wordpress.org/support/users/pressshack/)
 * (@pressshack)
 * [9 years ago](https://wordpress.org/support/topic/notification-on-trashed-post/#post-9157247)
 * Hi imagefact,
 * Thank you, You’re very welcome.
 * We don’t have an option for that right now, but we have 2 filters you can hook:
 * `pp_notification_status_change` or `pp_notification_{post_type}_status_change`
 * Those filters receive as params: $new_status, $old_status, $post.
 * If you return false, the notification won’t be sent.
 * Please, let us know if you need any further help.
 * Kind regards,
 *  Thread Starter [imagefact](https://wordpress.org/support/users/imagefact/)
 * (@imagefact)
 * [9 years ago](https://wordpress.org/support/topic/notification-on-trashed-post/#post-9157623)
 * Thank you! So would it be like this?
 *     ```
       /* Change PublicPress notifications trigger  		*/
       /* Don't Trigger notification when trashing posts 	*/
       add_filter('pp_notification_status_change', 'ppchangetrigger');
       function ppchangetrigger($new_status, $old_status, $post, 10,3){
           if $new_status === "trash" {
           	return false;
           }
           return;
       }
       ```
   
 * ALSO ANOTHER QUESTION:
    This is sortof the opposite from above, where I WANT 
   to trigger a notification on publish, but it’s not working:
 * I’m using the wp-types plugins and I have a front-end submit button (Cred-Submit)
   that pubishes posts from the front-end form. It doesn’t seem to be triggering
   your notification. One thought is that their priority is set later than yours.
 * 1 – Where can I find the priority in your plugin to set it at late as possible
   to see if that fixes the problem.
    2 – Any other thoughts on what could fix this?
 * I will also see if I can find any solution on their end, but thought I’d start
   with this.
 *  [PressShack](https://wordpress.org/support/users/pressshack/)
 * (@pressshack)
 * [9 years ago](https://wordpress.org/support/topic/notification-on-trashed-post/#post-9157741)
 * Yes, except it would be better to return true, in case it is not deleting.
 *     ```
       /* Change PublicPress notifications trigger */
       /* Don't Trigger notification when trashing posts */
       add_filter('pp_notification_status_change', 'ppchangetrigger');
       function ppchangetrigger($new_status, $old_status, $post, 10,3){
       if $new_status === "trash" {
       return false;
       }
       return true;
       }
       ```
   
 * Re the second question, if the notification works when you publish in the back-
   end, your idea might be correct. If it doesn’t, it is probably a bug and if you
   confirm, we can help you on that.
    Considering it works in the back-end, you 
   need to double check how the plugin you are using to publish from the front-end
   triggers the publish action.
 * We hook to this action: transition_post_status
    More info: [https://codex.wordpress.org/Post_Status_Transitions](https://codex.wordpress.org/Post_Status_Transitions)
 * The priority of our action is 10, but right now it is hard-coded, there is no
   way to change it without modifying the code (not recommended).
 * You can try checking if our method is being called when you publish from the 
   front-end:
 * publishpress/modules/notifications/notifications.php (line 534)
 *  Thread Starter [imagefact](https://wordpress.org/support/users/imagefact/)
 * (@imagefact)
 * [9 years ago](https://wordpress.org/support/topic/notification-on-trashed-post/#post-9157950)
 * Ok, that code caused a lockout of the site. But this code works:
 *     ```
       /* Change PublicPress notifications trigger */
       /* Don't Trigger notification when trashing posts */
       add_filter('pp_notification_status_change', 'ppchangetrigger');
       function ppchangetrigger($new_status) {
       if ($new_status === "trash") {
       		return false;
       	}
       return true;
       }
       ```
   
 * As for the other problem of triggering a notification on submitting a post. What
   I thought seemed to be true. On the page you sent:
    publishpress/modules/notifications/
   notifications.php
 * On line 108 I changed the 10 to a 10000 and it then works:
    `add_action('transition_post_status',
   array($this, 'notification_status_change'), 10000, 3);`
 * But of course, this is hardcoded and will get lost. So I have 2 questions for
   you:
 * 1 – If there a way around this?
    2 – Can you just permanently change this in 
   your code on next update? Will it cause conflicts for you/others?
 *  [PressShack](https://wordpress.org/support/users/pressshack/)
 * (@pressshack)
 * [9 years ago](https://wordpress.org/support/topic/notification-on-trashed-post/#post-9168798)
 * Hi,
 * Cool, I’m glad it worked.
 * 1. Yes
    2. I changed it, but I can’t set a hardcoded value again. I refactored
   the code allowing you customize that priority. You can try using the following
   package:
 * [https://www.dropbox.com/s/g3km7xx3c4xqnqo/publishpress.zip?dl=0](https://www.dropbox.com/s/g3km7xx3c4xqnqo/publishpress.zip?dl=0)
 * After installing the alpha package you can set your own value, defining the following
   constant:
 * `define( 'PP_NOTIFICATION_PRIORITY_STATUS_CHANGE', 10000 );`
 * Please let us know if that works for you.
 * Thanks

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

The topic ‘Notification on Trashed Post’ is closed to new replies.

 * ![](https://ps.w.org/publishpress/assets/icon-256x256.png?rev=3522502)
 * [PublishPress Planner - Editorial Calendar, Marketing Content, Kanban Board](https://wordpress.org/plugins/publishpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/publishpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/publishpress/)
 * [Active Topics](https://wordpress.org/support/plugin/publishpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/publishpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/publishpress/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [PressShack](https://wordpress.org/support/users/pressshack/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/notification-on-trashed-post/#post-9168798)
 * Status: resolved