/** * Delete a Permission Group * @param array group_id * @param array agent_type (pp_group, bp_group, etc.) */ function pp_delete_group($group_id, $agent_type) { require_once dirname(__FILE__) . '/admin/groups-update_pp.php'; return PP_GroupsUpdate::delete_group($group_id, $agent_type); }
function act_delete_users($user_ids, $blog_id_arg = 0) { require_once dirname(__FILE__) . '/groups-update_pp.php'; foreach ((array) $user_ids as $user_id) { PP_GroupsUpdate::delete_user_from_groups($user_id); } ppc_delete_agent_permissions($user_ids, 'user'); }
/** * Edit group settings based on contents of $_POST * * @param int $group_id Optional. Group ID. * @return int group id of the updated group */ function _pp_edit_group($group_id = 0, $agent_type = 'pp_group', $members_only = false) { global $wpdb; if ($group_id) { $update = true; $group = pp_get_group($group_id, $agent_type); } else { $update = false; $group = (object) array(); } if (!$members_only) { if (isset($_REQUEST['group_name'])) { $group->group_name = sanitize_text_field($_REQUEST['group_name']); } if (isset($_REQUEST['description'])) { $group->group_description = sanitize_text_field($_REQUEST['description']); } $errors = new WP_Error(); /* checking that username has been typed */ if (!$group->group_name) { $errors->add('group_name', __('<strong>ERROR</strong>: Please enter a group name.', 'pp')); } elseif (!$update && !PP_GroupsUpdate::group_name_available($group->group_name, $agent_type)) { $errors->add('user_login', __('<strong>ERROR</strong>: This group name is already registered. Please choose another one.', 'pp')); } // Allow plugins to return their own errors. do_action_ref_array('pp_group_profile_update_errors', array(&$errors, $update, &$group)); if ($errors->get_error_codes()) { return $errors; } if ($update) { PP_GroupsUpdate::update_group($group_id, $group, $agent_type); } else { $group_id = PP_GroupsUpdate::create_group($group, $agent_type); } } if ($group_id) { $member_types = array(); if (pp_has_group_cap('pp_manage_members', $group_id, $agent_type)) { $member_types[] = 'member'; } foreach ($member_types as $member_type) { if (isset($_REQUEST["{$member_type}_csv"]) && $_REQUEST["{$member_type}_csv"] != -1) { // handle member changes $current = pp_get_group_members($group_id, $agent_type, 'id', compact('member_type')); $selected = isset($_REQUEST["{$member_type}_csv"]) ? explode(",", pp_sanitize_csv($_REQUEST["{$member_type}_csv"])) : array(); if ('member' != $member_type || !apply_filters('pp_custom_agent_update', false, $agent_type, $group_id, $selected)) { if ($add_users = array_diff($selected, $current)) { pp_add_group_user($group_id, $add_users, compact('agent_type', 'member_type')); } if ($remove_users = array_diff($current, $selected)) { pp_remove_group_user($group_id, $remove_users, compact('agent_type', 'member_type')); } } } } // end foreach member_types do_action('pp_edited_group', $agent_type, $group_id, $update); } return $group_id; }