[Resolved] Send notification to the post author, after a checkbox generic field is selected
This support ticket is created 5 years, 8 months 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.
Tell us what you are trying to do?
I would like to send a notification / message to the post author, after selecting a generic field / checkbox in a view/filter , as per the attachment. Please help.
thx
Is there any documentation that you are following?
In the conditions for form notifications there is no condition to test the value of a field included in the form (whether a Types field or a generic field) at the time the form is submitted.
The only condition relating to custom field values is for when a custom field value changes (e.g. is edited in the backend at some future time). Generic fields wouldn't work here because they are not saved, and so cannot be changed.
In your case you need to use the Forms API and write some custom code which uses the cred_notification_event_type hook to create a custom condition, and the cred_custom_notification_event_type_condition hook to return true or false depending on whatever it is you test (e.g. whether a generic field that is available in the $_POST object is checked).
This other thread shows the basics of what's required, are you able to expand upon that to include the condition you want to test?
Hi Nigel, sorry I was not very clear in my explanation, let me please clarify what I am looking for: I have a content template that is placed in a layout, which list the custom posts as a table (no option for notification in layouts). I would like that the site users can select some of the posts using checkboxes (displayed in the same row with the posts) and then to have the possibility to press a SEND button to sent all of those posts titles to a specific email address predefined by us. We will use this to quickly find out what the the posts interested for the visitor. So we would like to receive the post titles selected by the user, and the user name or ID. Thx. Valentin
OK, you might need to jump through a few hoops to set this up, including writing some custom code.
Notifications are a feature of Forms, so the solution must involve submitting a form to publish a post.
I would try something like the following:
- create a custom post type for the submissions, called "requests" or some such name
- add a multi-select custom field with some fake options that will be dynamically replaced; you'll want to store post ids as values and use post titles as labels
- create a Form to publish requests which includes this field
- add a notification that outputs details of the user (they will, for example, be the author of the post) and outputs that field
- use the wpt_field_options filter to dynamically modify the options included in the multi-select field
So the user would be able to select multiple posts in this request form, and the notification report the selected posts and user info.
That's about the closest I can get to your request without a completely bespoke solution.
There is an alternative you could try that would avoid having to use the wpt_field_options filter and which might let you offer the post titles with checkboxes.
You could add a generic checkboxes field to the form and provide the options for the field via a View which outputted the post titles and IDs in JSON format as required by the generic field.
Add a "persist":1 option to the generic field for the values to be saved to the database which should make them available in the notification.
(I think you would need to create a Types checkboxes field and assign it to the requests post type, but in the form itself use a generic checkboxes field with the same key (i.e. the field slug plus the prefix of 'wpcf-') so that you can use a Types shortcode to output the field in the notification body.