function remove_instructor_invite() { $user_id = (int) $_POST['user_id']; $course_id = (int) $_POST['course_id']; $invite_code = sanitize_text_field($_POST['invite_code']); $nonce_check = wp_verify_nonce($_POST['instructor_nonce'], 'manage-instructors-' . $user_id); $cap = CoursePress_Capabilities::can_assign_course_instructor($course_id, $user_id); // same capability as adding $doing_ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false; $ajax_response = array(); $ajax_status = 1; //success if ($nonce_check && $cap && $doing_ajax) { $instructor_invites = get_post_meta($course_id, 'instructor_invites', true); unset($instructor_invites[$invite_code]); update_post_meta($course_id, 'instructor_invites', $instructor_invites); $ajax_response['invite_removed'] = true; $ajax_response['content'] = __('Instructor invitation cancelled.', 'cp'); /** * Instructor invite has been cancelled. * * @since 1.2.1 * * @param int course_id The course instructor was added to. * @param int invite_code The code of the invite that was cancelled. * */ do_action('coursepress_instructor_invite_cancelled', $course_id, $invite_code); } else { $ajax_response['invite_removed'] = false; $ajax_response['reason'] = __('Invalid request. Security check failed.', 'cp'); /** * Instructor invite has NOT been cancelled. * * @since 1.2.1 * * @param int course_id The course instructor was added to. * @param int invite_code The code of the invite that was cancelled. * */ do_action('coursepress_instructor_invite_not_cancelled', $course_id, $invite_code); } $response = array('what' => 'remove_instructor_invite', 'action' => 'remove_instructor_invite', 'id' => $ajax_status, 'data' => json_encode($ajax_response)); ob_end_clean(); ob_start(); $xmlResponse = new WP_Ajax_Response($response); $xmlResponse->send(); ob_end_flush(); }
<div class="instructors-info" id="instructors-info"> <?php if (0 >= cp_instructors_avatars($course_id, true, true)) { ?> <div class="instructor-avatar-holder empty"> <span class="instructor-name"><?php _e('Please Assign Instructor', 'cp'); ?> </span> </div> <?php } ?> <?php $can_manage_instructors = CoursePress_Capabilities::can_assign_course_instructor($course_id); ?> <?php cp_instructors_avatars($course_id, $can_manage_instructors); ?> <?php cp_instructors_pending($course_id, $can_manage_instructors); ?> </div> <div class="clearfix"></div> <?php if ($can_manage_instructors || 0 == $course_id) { ?> <hr/>