Skip Navigation

[Resolved] How to create an email alert from a list within a CRED form

This support ticket is created 7 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 7 years ago.

Assisted by: Christian Cox.

Author
Posts
#596731

Tell us what you are trying to do? I'd like to allow an author to select several posts within a list and include them in an email sent to a particular or several recipients.

Unless there exists a better and simpler solution, I thought about creating a form listing posts and making them selectable (how?) and then, after hitting the submit button, using the CRED notification system to send emails to several recipients; the selection of those recipients should also be possible within the CRED form.

Any idea?
Thanks.

#596949

I think this is going to require quite a bit of custom code, and some clever use of CRED's API. This is the general idea:
- Create a new custom post type called "Email Digests" or something similar.
- Create a new post CRED form that creates Email Notifications posts. Add a generic checkboxes field that includes options for each possible User, and another generic checkboxes field that includes options for each possible Post. To automate this process, you may use Views to generate the output for the checkboxes options. Refer to this post for more information about providing generic field options with Views: https://toolset.com/forums/topic/how-use-a-shortcode-instead-of-options-for-cred-forms
- Add an email notification to this CRED form, and place the post body in the email message using the shortcodes available in the notification message editor.
- Use the CRED API method "cred_before_save_data" to capture the selections from your generic fields.
- Use a custom WP Query to get the post contents of each of the selected posts, and concatenate them all into a single text string.
- Use PHP to manipulate the new post's content to include the concatenated string. The Email Digest post body, containing all the selected posts, will be sent in the email because you placed the post body shortcode in the message editor earlier.
- Store the selected user IDs in a custom field on the Email Digest post type, so you can access them later. You can use update_post_meta for this.
- Manipulate the email notification recipients using this user ID custom field and the CRED API "cred_notification_recipients" method: https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients

I can give more general information here if you'd like, but if you need in-depth assistance on any of these steps I kindly ask you to open separate tickets for each question. This will be a complex feature that will be difficult to capture completely in a single ticket.

#597033

Hello Christian,

What a fantastic and inspiring answer, Thank you!
As this will take some time to process and experiment, I will leave this ticket open for a few days to see whether there is more general information needed or, as you kindly suggested, go for more dedicated tickets.

Thanks again.

#597458

Great, I will mark this ticket as pending an update from you. No need to reply right away. The ticket will stay open for 30 days.