/** * GROUP EDIT & USER PROFILE. Handles ajax requests to remove a group from a users account * * @global wpdb $wpdb */ public static function remove_group_from_user() { global $wpdb, $current_user; $response = array(); //Added in 1.1 - ensures current user is an admin before processing, else returns an error (probably not necessary - but just in case...) if (!current_user_can('promote_users')) { //ERROR! - membership not found. $response = new WP_Ajax_Response(array('what' => 'unenroll', 'action' => 'remove_group_from_user', 'id' => new WP_Error('error', __('User is not authorized.', 'contexture-page-security')))); $response->send(); } if (!CTXPS_Queries::delete_membership($_REQUEST['user_id'], $_REQUEST['group_id'])) { //Error - membership not found. $response = array('what' => 'unenroll', 'action' => 'remove_group_from_user', 'id' => new WP_Error('error', __('User not found in group.', 'contexture-page-security'))); } else { //SUCCESS! $response = array('what' => 'unenroll', 'action' => 'remove_group_from_user', 'id' => 1, 'data' => __('User removed from group.', 'contexture-page-security'), 'supplemental' => array('html' => CTXPS_Components::render_group_list($_REQUEST['user_id'], 'users', current_user_can('promote_users'), $_REQUEST['user_id'] == $current_user->ID))); } $response = new WP_Ajax_Response($response); $response->send(); }
//Make sure user isnt already in the group if (CTXPS_Queries::check_membership($AddUserId, $_GET['groupid']) > 0) { $actionmessage = '<div class="error below-h2"><p>' . __('User is already in this group.', 'contexture-page-security') . '</p></div>'; } else { //Add user to group if (CTXPS_Queries::add_membership($AddUserId, $_GET['groupid']) === false) { $actionmessage = '<div class="error below-h2"><p>' . __('An error occurred. User could not be added to the group.', 'contexture-page-security') . '</p></div>'; } else { $actionmessage = sprintf('<div id="message" class="updated below-h2"><p>' . __('User "%s" has been added to the group.', 'contexture-page-security') . '</p></div>', esc_attr($_GET['add-username'])); } } } break; case 'rmvusr': //Remove the user from the group if (CTXPS_Queries::delete_membership($_GET['usrid'], $_GET['groupid']) === false) { $actionmessage = '<div class="error below-h2"><p>' . __('An error occurred. User could not be removed from group.', 'contexture-page-security') . '</p></div>'; } else { $actionmessage = sprintf('<div id="message" class="updated below-h2"><p>' . __('User "%s" was removed from the group.', 'contexture-page-security') . '</p></div>', esc_attr($_GET['usrname'])); } break; default: break; } } $groupInfo = CTXPS_Queries::get_group_info($_GET['groupid']); if (empty($groupInfo->group_site_access)) { $groupInfo->group_site_access = 'none'; } $dbopts = get_option('contexture_ps_options'); // if($_GET['page']==='ps_groups_edit') //What was this supposed to do?