Skip Navigation

[Resolved] Automating Emails

This support ticket is created 2 years, 5 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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by Bob 2 years, 5 months ago.

Assisted by: Jamal.

Author
Posts
#2209503

Bob

I've got a lending library system built with Toolset. I have custom post types of Members and Items (books) when a member borrows a book the Item record is updated with a due date and a relationship formed.
I'm looking for some guidance on how to go about the following:
For all Items close to their due date I want to send an email to the Member (email address is help within their post), ideally as a regular job (I'm thinking nightly CRON job) or to have a view that an operator can run then click to send an email to each record.

I realise this is likely to be custom code or another plugin but I'd appreciate any advice from your experiences.

TIA

#2209979

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello TIA and thank you for contacting Toolset support.

Honestly, I might need more details about your setup to better advise. But, I still believe there should be a solution without custom code.

For example, your idea about using a view for operators to trigger the email might not need any custom code at all. If you can put the email of the user inside the form(either through a custom field or a generic field), you may trigger an email notification by submitting the form. You can use an edit form that has the email field, and a submit button. Once the form is submitted it will trigger the email notifications that are configured on it.
https://toolset.com/course-lesson/send-notifications-when-someone-submits-the-form/

If the post to edit, using this form, does not include the email address, you will need custom code to get it from a related post. The following article on creating custom placeholder is worth checking https://toolset.com/documentation/programmer-reference/forms/how-to-use-custom-placeholders-in-cred-notifications/

Based on how you are implementing your website, maybe you can use the expiration feature of Toolset forms. Expirations can also trigger notification emails. This is basically relevant if you are storing a "Borrowing" event as a post instead of a custom field. Check this article https://toolset.com/course-lesson/setting-up-automatic-post-expiration/

But, if you want to use CRON jobs, you will definitely need custom code. I can't suggest what to do without knowing more about your use case. But, I can imagine that the code will use WP_Query with some date arguments to get the items that are relevant. Then, it will build and send the email.
- https://developer.wordpress.org/reference/classes/wp_query/
- https://developer.wordpress.org/reference/functions/wp_mail/

Keep in mind that Toolset stores date fields as timestamps.

I hope this helps. Let me know if you have any questions.

#2210075

Bob

Thanks Jamal, that's given me somewhere to start which is exactly what I needed.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.