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
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.