[Resolved] Sending notification e-mail specified in a custom field
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.
I would like an automatic notification email to be sent to the e-mail address specified in a custom field of a custom post, if the custom post status changes to "published".
The usual settings under the "post form > e-mail notifications > notification e-mail recipients > Send notification to an e-mail specified in an email field included in the form" seems not to be working.
Can you support me with a code that I can include to my functions.php file that will solve the following:
- if the status of the custom post "Gedenkseite" (slug 'gedenkseite') changes to "published"
- then the e-mail notification with the subject and body specified under the post form called "Gedenkseite veröffentlichen" (Formular-Slug: gedenkseite-veroeffentlichen) should be sent to the e-mail address specified under the custom post type "Gedenkseite" as a custom field "E-Mail Angehörige" ('wpcf-emailangehorige')
PS! A new custom post "Gedenkseite" is always generated manually in the back end, there is no form in the front end for guests to generate those posts.
PPS! Just for the info. For 3 years I had a similar problem, but then it was a bit more complex as it included parent post and child post and a form in the front end. Back then a small code in the functions.php solved the problem. Maybe something similar also this time?
I've performed some testing and research, and couldn't find any straightforward filter/hook that can be used in the custom code to trigger the form notification, without the form being submitted.
A more reliable approach in this case would be to continue to create these posts through the admin area in the back end, without 'publish' status.
And for changing the status to 'publish', you can create a front-end page, that will include the view that shows the list of all the 'unpublished' posts.
And in that view's loop item, you can show an edit form, that will only have the submit button, without any fields. In settings, you can set the form to change the status of the post to 'publish'. And, in that form's notification settings, you can set the email message that should be sent, when the form is submitted.
I hope this helps and please let me know if you need further assistance.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.