/** * GROUP MEMBER TABLE. Handles ajax requests to update a users membership info * * @global wpdb $wpdb */ public static function update_membership() { global $wpdb; //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! If user isn't authorized, stop and return error $response = new WP_Ajax_Response(array('what' => 'update', 'action' => 'update_membership', 'id' => new WP_Error('error', __('User is not authorized.', 'contexture-page-security')))); $response->send(); } //Determine if we need to pass NULL or a DateTime value... $db_expires = $_POST['expires'] == '1' ? $_POST['date'] : 'NULL'; //Determine response if (CTXPS_Queries::update_enrollment_grel($_POST['grel'], $db_expires) === false) { $response = array('what' => 'update', 'action' => 'update_membership', 'id' => new WP_Error('error', __('Query failed.', 'contexture-page-security'))); } else { $response = array('what' => 'update', 'action' => 'update_membership', 'id' => 1, 'data' => __('User membership updated to ' . $db_expires, 'contexture-page-security')); } $response = new WP_Ajax_Response($response); $response->send(); }