# taskbuilder/6.0.6/includes/admin/projects/wppm_set_project_meta.php

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

- Page: https://pluginprobe.com/plugins/taskbuilder/6.0.6/code/includes/admin/projects/wppm_set_project_meta.php
- Raw: https://pluginprobe.com/plugins/taskbuilder/6.0.6/raw/includes/admin/projects/wppm_set_project_meta.php
- Modified: 2026-08-26T12:08:58+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.6/code/includes/admin/projects/wppm_set_project_meta.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) {
  exit; // Exit if accessed directly
}
global $wpdb,$wppmfunction,$current_user;
$project_id = intval(sanitize_text_field($project_id));
$project_data = $wppmfunction->get_project($project_id);
$users = explode(',',$project_data['users']);
$users = array_unique($users);
if(!empty($users)){
  foreach($users as $user){
    if(!empty($user)){
      $user_role = sanitize_text_field(wp_unslash($_POST['wppm_select_user_role_'.$user]));
      $project_user = $wpdb->get_row(
        $wpdb->prepare(
          "SELECT * FROM {$wpdb->prefix}wppm_project_users WHERE proj_id = %d AND user_id = %d",
          absint($project_id),
          absint($user)
        )
      );
      if(!empty($project_user)){
        $project_user_id = absint($project_user->id);
        $values=array(
          'role_id'=> absint($user_role),
          'assigned_by'=>absint($current_user->ID)
        );
        $wpdb->update($wpdb->prefix.'wppm_project_users', $values, array('id'=>$project_user_id));
      }else{
        $wpdb->insert( 
          $wpdb->prefix . 'wppm_project_users', 
          array(
            'proj_id' => absint($project_id),
            'user_id' => absint($user),
            'role_id' => absint($user_role),
            'assigned_by' =>absint($current_user->ID)
        ) );
      }
    }
  }
}
```
