/** * Set the role for the given employees * * @param int|arr $employees Required: Single user ID or array of user ID's to adjust * str $role Required: The role ID to which the users will be moved * * @return */ public function set_role($employees, $role) { mdjm_set_employee_role($employees, $role); }
/** * Init * * * */ public static function init() { global $wp_roles; // Listen for post requests // Update the user role if (isset($_POST['change_role'], $_POST['new_role'], $_POST['employees'])) { foreach ($_POST['employees'] as $employee) { mdjm_set_employee_role($employee, $_POST['new_role']); } mdjm_update_notice('updated', __('Employee roles updated.', 'mobile-dj-manager'), true); } wp_enqueue_script('jquery-validation-plugin'); self::$all_roles = $wp_roles; // Filter our search by role if we need to self::$display_role = !empty($_GET['display_role']) ? $_GET['display_role'] : ''; self::$orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : ''; self::$order = !empty($_GET['order']) ? $_GET['order'] : ''; // Which tab? self::$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'user_roles'; // Display the page tabs self::page_header(); // Retrieve all MDJM roles self::$mdjm_roles = mdjm_get_roles(); self::$total_roles = count(self::$mdjm_roles); // Determine the page to display if (self::$active_tab == 'permissions') { self::permissions_manager(); } else { // Instantiate the user table class self::$mdjm_employee_table = new MDJM_Employee_Table(); self::$mdjm_employee_table->process_bulk_actions(); // Retrieve employee list self::$employees = empty($_POST['s']) ? mdjm_get_employees(self::$display_role, self::$orderby, self::$order) : self::search(); self::$total_employees = count(mdjm_get_employees()); self::$mdjm_employee_table->prepare_items(); // The header for the user management page self::employee_page(); } }