We have a form set up to let us know when visitor parking has been selected in the form, and an edit form notification for if a user changes the parking field, which works well.
But if a user deletes their visitor entry, we receive a notification with all blank fields, like the below, is there any way round this? or to get an notification, that they have deleted it but with the actual details?
Name:
Company:
email:
Visitor Details
Name:
Company:
Arrival date:
Departure date:
Parking Request
Request visitor parking:
Time:
Hi, how exactly is this delete post notification triggered when someone submits a Form? As far as I know there is no email notification triggered on post delete, unless there is some custom code in place that taps into the trash_post event hook. In the past I've recommended using an Edit Post form to set the post status to "draft", then trigger the notification from that Form: https://toolset.com/forums/topic/notifications-on-delete-post-type/#post-596976
Hi, yes I found it strange, this is the code in the table of the view for users to delete their visitor -
<td>[cred_delete_post_link action='trash' text='Delete ' message='Are you sure you want to delete this post?' message_show='1' class='cred-refresh-after-delete']</td>
In the notification we have
Notification e-mail trigger > When custom fields are modified > Only if field value has changed
Could that be why?
Normally deleting a post would not trigger this notification, unless I'm misunderstanding things. I could log in and create a clone to see what's going on, if you provide login credentials and show me where to trigger the delete post.
Okay I created a clone and installed it locally on my own testing environment. I deactivated all plugins except Types, Views, Forms, Access, Duplicator Pro, and WP Mail Logging. While logged-in as developer, I created a new Visitor using the Visitor form on the /info/add-a-visitor page. Then I saw that Visitor appear in the View on the /my-visitors page. I clicked "Delete" and the visitor was successfully deleted. In the mail logs I noticed one mail appear. The notification email subject was HQ - Visitor parking request. I checked the Form to see which notification this message corresponds to, but they all have the same subject so I wasn't sure. At that point I decided I should add some text to each notification subject line so I could easily determine which notification was being triggered. I saved the Form and began testing again by creating a new Visitor. This time when I deleted the Visitor, no email was triggered.
So I ran the same test 4 more times with the same results each time - no email is triggered when deleting the Visitor. So I am curious to see if simply re-saving the Form on your live site will stop the problem occurring for new Visitor posts in the future. Would you like to test that on the live site?
Thanks for testing.
You are right, I re saved the notifications, and no email is triggered on deleting a visitor. Which is great!
But on saving the notifications, I lost all formatting of the visitor form and has to reformat the forms. Do you know what could be causing that?
The Form looks pretty much the same on the front-end for me before and after saving to update the email notifications. When you say the format was lost, are you referring to the layout of the input fields in the builder, or custom classes and CSS styles you added to the form? Or the format of one of the notifications changed?
It was the formatting in the form builder that is lost when we save the form, but happens randomly, it also happens if we copy the form, it doesn't copying the formatting over to the new form.
We received another blank notification again today.
So have now removed the delete post option and followed your suggestion here - https://toolset.com/forums/topic/notifications-on-delete-post-type/#post-596976
And it's working well.
Thanks for your help.