# taskbuilder/6.0.2/includes/admin/email_notifications/wppm_en_project_created.php

Taskbuilder – Project Management &amp; Task Management Tool With Kanban Board, version 6.0.2. 87 lines.

- Page: https://pluginprobe.com/plugins/taskbuilder/6.0.2/code/includes/admin/email_notifications/wppm_en_project_created.php
- Raw: https://pluginprobe.com/plugins/taskbuilder/6.0.2/raw/includes/admin/email_notifications/wppm_en_project_created.php
- Modified: 2026-08-22T18:03:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/taskbuilder/6.0.2/code/includes/admin/email_notifications/wppm_en_project_created.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) {
  exit; // Exit if accessed directly
}

global $wppmfunction, $current_user,$wpdb;
$from_name     = get_option('wppm_en_from_name');
$from_email    = get_option('wppm_en_from_email');
$ignore_emails = get_option('wppm_en_ignore_emails');
$project_id = intval(sanitize_text_field(($project_id)));
$project_id = absint($project_id);
$project_data = $wppmfunction->get_project($project_id);
$proj_users = $project_data['users'];
$proj_users = explode(',',$proj_users);
$email_addresses = array();
if ( !$from_name || !$from_email ) {
  return;
}
$wppm_email_notificatins = get_option('wppm_email_notification');
$wppm_default_email_notification_to_current_user = get_option('wppm_default_email_notification_to_current_user');
if(!empty($wppm_email_notificatins)){
  foreach ($wppm_email_notificatins as $key=>$val) :
    if($val['type']=='new_project'){
      $subject  = $wppmfunction->replace_macro(stripslashes($val['subject']), $project_id);
      $body  = $wppmfunction->replace_macro(stripslashes($val['body']),$project_id);
      $recipients = $val['recipients'];
      foreach ($recipients as $recipient) {
        if(is_numeric($recipient)){
          if($recipient == 1 && !empty($proj_users)) {
            foreach($proj_users as $user){
              if(!empty($user)){
                $user = absint($user);
                $project_user_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wppm_project_users WHERE proj_id = %d AND user_id = %d",$project_id,$user));
                $userdata = get_userdata($user);
                if((!empty($project_user_data)) && $project_user_data->role_id == 1){
                  $email_addresses[] = $userdata->user_email;
                } 
              }
            }
          } 
          elseif($recipient == 2 && !empty($proj_users)){
            foreach($proj_users as $user){
              if(!empty($user)){
                $user = absint($user);
                $project_user_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wppm_project_users WHERE proj_id = %d AND user_id = %d",$project_id,$user));
                $userdata = get_userdata($user);
                if((!empty($project_user_data)) && $project_user_data->role_id == 2){
                  $email_addresses[] = $userdata->user_email;
                } 
              }
            }
          }
        } else{
          switch ($recipient) {
            case 'project_creator':
              $email_addresses = array_merge($email_addresses,$wppmfunction->get_project_creator_email($project_id));
              break;
          }
        }
      }
      $email_addresses = array_unique($email_addresses);
      $email_addresses = array_diff($email_addresses,$ignore_emails);
      if(empty($wppm_default_email_notification_to_current_user)){
        $email_addresses = array_diff($email_addresses,array($current_user->user_email));
      }
      $email_addresses = apply_filters('wppm_en_project_users_email_addresses',$email_addresses,$val,$project_id);
      $email_addresses = array_values($email_addresses);

      $to =  isset($email_addresses[0])? $email_addresses[0] : '';
      if($to){
        unset($email_addresses[0]);
      } else {
        continue; // no email address found to send. So go to next foreach iteration.
      }

      $bcc = implode(',',$email_addresses);
      $headers  = "From: {$from_name} <{$from_email}>\r\n";
      $email_addresses = explode(',',$bcc);
      foreach ($email_addresses as $email_address) {
        $headers .= "BCC: {$email_address}\r\n";
      }
      $headers .= "Content-Type: text/html; charset=utf-8\r\n";
      wp_mail($to, $subject, $body, $headers);
      do_action('wppm_after_project_created_mail',$project_id,$val);
    }
  endforeach;
}
```
