Filter: WP-CRM System Email Notifications Task

The wp_crm_system_email_notifications_task filter allows you to modify the various variables used to send an email notification for task.

The filter is passed one argument as an array:

$send_email    = array(
    'send'        => true,
    'vars'        => $vars,
    'to'        => $to,
    'subject'    => $subject,
    'message'    => $message,
    'headers'    => $headers,
    'id'        => $ID,
    'post'        => $post,

The variables in the array can be used to modify a number of behaviors including how frequently a notification is sent, who it is sent to, the subject , message, and the headers sent along with the message.

In order for the email to be sent, $send_email[‘send’] must be true, which it is by default. If for some reason a condition is met where you do not want the email to be sent again, you can use the filter to set $send_email[‘send’] to false, which will prevent the email from sending.

When this filter is run, you can set custom metadata for the task that can be used in the future, or use existing data to determine if an email should be sent, who it should be sent to, and more.

For example:

// Only send email if the project status is 'complete'
add_filter( 'wp_crm_system_email_notifications_task', 'prevent_sending_until_project_complete' );
function prevent_sending_until_project_complete( $send_email ){
    $status = get_post_meta( $send_email['id'], '_wpcrm_task-status', true );
    if( 'complete' != $status ){
        $send_email['send'] = false;
    return $send_email;
// Only send email when the assigned user is changed
add_filter( 'wp_crm_system_email_notifications_task', 'send_assigned_user' );
function send_assigned_user( $
    // Assigned user in WP-CRM System
    $assigned = get_post_meta( $send_email['id'], '_wpcrm_task-assignment', true );

    // Get previous assigned user
    $previous = get_post_meta( $send_email['id'], '_wpcrm_task_email_notification_previously_assigned', true );

    if( $assigned == $previous ){
        // The assigned user is the same as the previously assigned user, so prevent sending.
        $send_email['send'] = false;
    } else {
        // Set the currently assigned user as a custom post meta value so we can check for it again in the future.
        update_post_meta( $send_email['id'], '_wpcrm_task_email_notification_previously_assigned', $assigned );
    return $send_email;