Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adrianosferreira/ca3cbe3e2ab49935e12b to your computer and use it in GitHub Desktop.
Save adrianosferreira/ca3cbe3e2ab49935e12b to your computer and use it in GitHub Desktop.
/*
* This will let you add a custom event for your notification
* If the custom field is equal today the notification will be triggered
*/
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;
}
}
@maximejobin
Copy link

Missing ";" on line 12. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment