Skip Navigation

[Resolved] Send e-mail notifications at individual dates

This support ticket is created 6 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
- 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 6 years ago.

Assisted by: Luo Yang.

Author
Posts
#1183757

Hi!

I'm having a problem similar to this one https://toolset.com/forums/topic/send-email-notification-at-future-date/ and wanted to inquire if there has been an update that could help me.

I need to send e-mail notifications at certain dates that are different for each post of a category. I have a custom post type "clients", the posts are created with a CRED post form. In the form, there are up to two date fields that are relevant. I'd like to send reminders to the clients when those dates equal today. Is there a way I can achieve that?

Thank you very much!

Best,
Tanja

#1184020

Dear Tanja,

There isn't such a built-in feature within Toolset forms, I have checked the thread you mentioned above in our to-do list, our developers have provide some example codes to achieve it with filter hooks, for example, the post is created with a post form(ID 123), and you are going to send the email notification by custom date field "my-date-field", you can use below custom PHP codes:

add_filter( 'cred_notification_event_type', 'my_custom_event_type', 99, 4);
function my_custom_event_type($notification_type, $form_id){
    if( $form_id == '123' )
        return 'data_custom_field';
}

add_filter( 'cred_custom_notification_event_type_condition', 'my_custom_event', 99, 4)
function my_custom_event( $bool, $notification, $form_id, $post_id ){
    if( $form_id == '123' ){
        $date_field = get_post_meta( $post_id, 'wpcf-my-date-field', true );
        $current_date = date('Y-m-d');

        if( strtotime( $current_date ) == $date_field )
            return true;
    }
}

This is only an example codes for your reference.

more help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_event_type
This hook is used to create a custom event type for notifications.

https://toolset.com/documentation/programmer-reference/cred-api/#cred_custom_notification_event_type_condition
This hook is used during evaluation of a custom notification condition, when the event type is custom.