[Resolved] Posts created through Post Form that are in draft status still send emails
This thread is resolved. Here is a description of the problem and solution.
Problem:
Posts created with a Toolset Form that are set to expire send a warning notification ahead of the expiration.
If a post is trashed, how can those notifications be turned off?
Solution:
Details of the notification are stored in a hidden custom field '_cred_post_expiration_notifications', and this field can be deleted when a post is trashed, using the wp_trash_post hook.
This support ticket is created 5 years ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
We have user posts created through a CRED post form that, when users choose to take them off the site, are turned to drafts so they can be reactivated later if need be. These posts have expiration dates set when they are created, and automatic emails sent when the expiration time nears. Posts that are drafts still send the automatic emails. Is there a way to stop this, so that emails are only sent from published posts?
We use the cred_delete_post_link shortcode (full code follows). It says the action is trash, but I know that somehow they're going to draft instead (we set this up a few years ago and I can't remember how exactly it works). Removing the post expiration when that happens would be just fine. The accounts are reactivated by admins, and that happens rarely, so they could just add an expiration back manually when it they reactivated the account.
[cred_delete_post_link class='cred-refresh-after-delete' text='Deactivate' message='Are you sure you want to deactivate this Land Seeker Listing? Note: if it says deleting it is not a problem, we will still have your post when you want to reactivate it.' message_after='Thank you for deactivating/deleting your post. To reactivate it, or if you have deleted it in error, please contact EMAIL REMOVED with the email address and user name of your account.' message_show='1' action='trash']
If you are using that shortcode to trash the posts but they are actually being changed to draft it must be that you are already using some custom code to intervene in the process, which we could modify to wipe the post expiration date.
If you are sure that this is happening (i.e. posts are switched to draft instead of trashed) can you find the code that is used and share it with me? (Check your theme's functions.php, or any plugin used for adding custom PHP snippets.)
In which case I can see when creating a test with the same set-up that a hidden custom field is added to posts that manages the notification related to post expiration, so we can simply delete that rather than removing the expiration itself.
We can hook into when a post is trashed, then strip that hidden custom field if it exists.