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,
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.
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
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)
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?
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
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