exists()) continue; if ($action === 'add' && $advausro_role_to_add) { // Fix: Support multi-role assignment by not removing existing roles $advausro_user->add_role($advausro_role_to_add); } $role_manager = ADVAUSRO_RoleManager::advausro_get_instance(); $protected_roles = $role_manager->advausro_get_protected_roles(); if ($action === 'remove' && $advausro_role_to_remove) { if (!in_array($advausro_role_to_remove, $protected_roles) && in_array($advausro_role_to_remove, $advausro_user->roles)) { $advausro_user->remove_role($advausro_role_to_remove); } } if ($bulk_action === 'delete') { if (get_current_user_id() !== $advausro_user_id) { // Determine if user has a protected role BEFORE deleting $is_protected = false; foreach ($protected_roles as $role) { if (in_array($role, $advausro_user->roles)) { $is_protected = true; break; } } if (!$is_protected) { require_once ABSPATH . 'wp-admin/includes/user.php'; wp_delete_user($advausro_user_id); } } } } // Bulk export is handled in ADVAUSRO_Connector::advausro_handle_exports() add_action('admin_notices', function () use ($action, $bulk_action, $advausro_user_ids) { $count = count($advausro_user_ids); if ($bulk_action === 'delete') { echo wp_kses_post('
Selected user(s) deleted successfully.
Added role to ' . (int)$count . ' user(s) successfully.
Removed role from ' . (int)$count . ' user(s) successfully.