示例#1
0
 /**
  * Output the content of the Roles column.
  *
  * @param string $output The existing HTML to display. Should be empty.
  * @param string $column The name of the current column.
  * @param int $user_id The user ID whose roles are about to be displayed.
  * @return string The new HTML output.
  */
 public function output_column_content($output, $column, $user_id)
 {
     if ('md_multiple_roles_column' !== $column) {
         return $output;
     }
     $roles = $this->model->get_user_roles($user_id);
     ob_start();
     include apply_filters('mdmr_column_template', MDMR_PATH . 'views/column.html.php');
     return ob_get_clean();
 }
示例#2
0
 /**
  * Update the given user's roles as long as we've passed the nonce
  * and permissions checks.
  *
  * @param int $user_id The user ID whose roles might get updated.
  */
 public function process_checklist($user_id)
 {
     do_action('mdmr_before_process_checklist', $user_id, $_POST['md_multiple_roles_nonce']);
     if (isset($_POST['md_multiple_roles_nonce']) && !wp_verify_nonce($_POST['md_multiple_roles_nonce'], 'update-md-multiple-roles')) {
         return;
     }
     if (!$this->model->can_update_roles()) {
         return;
     }
     $new_roles = isset($_POST['md_multiple_roles']) && is_array($_POST['md_multiple_roles']) ? $_POST['md_multiple_roles'] : array();
     if (empty($new_roles)) {
         return;
     }
     $this->model->update_roles($user_id, $new_roles);
 }