本文整理汇总了PHP中WooThemes_Sensei_Utils::sensei_remove_user_from_lesson方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::sensei_remove_user_from_lesson方法的具体用法?PHP WooThemes_Sensei_Utils::sensei_remove_user_from_lesson怎么用?PHP WooThemes_Sensei_Utils::sensei_remove_user_from_lesson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WooThemes_Sensei_Utils
的用法示例。
在下文中一共展示了WooThemes_Sensei_Utils::sensei_remove_user_from_lesson方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove_user_from_post
public function remove_user_from_post()
{
global $woothemes_sensei;
$return = '';
// Security check
$nonce = '';
if (isset($_POST['remove_user_from_post_nonce'])) {
$nonce = esc_html($_POST['remove_user_from_post_nonce']);
}
if (!wp_verify_nonce($nonce, 'remove_user_from_post_nonce')) {
die($return);
}
// Parse POST data
$data = $_POST['data'];
$action_data = array();
parse_str($data, $action_data);
if ($action_data['user_id'] && $action_data['post_id'] && $action_data['post_type']) {
$user_id = intval($action_data['user_id']);
$post_id = intval($action_data['post_id']);
$post_type = sanitize_text_field($action_data['post_type']);
$order_id = sanitize_text_field($action_data['order_id']);
$user = get_userdata($user_id);
switch ($post_type) {
case 'course':
$removed = WooThemes_Sensei_Utils::sensei_remove_user_from_course($post_id, $user_id);
if (!empty($order_id) && is_woocommerce_active()) {
$order = new WC_Order($order_id);
if (!empty($order)) {
$order->update_status('cancelled');
}
}
break;
case 'lesson':
$removed = WooThemes_Sensei_Utils::sensei_remove_user_from_lesson($post_id, $user_id);
break;
}
if ($removed) {
$return = 'removed';
}
}
die($return);
}
示例2: sensei_remove_user_from_course
/**
* Remove a user from a course, deleting all activities across all lessons
*
* @param type $course_id
* @param type $user_id
* @return boolean
*/
public static function sensei_remove_user_from_course($course_id = 0, $user_id = 0)
{
global $woothemes_sensei;
if (!$course_id) {
return false;
}
if (intval($user_id) == 0) {
$user_id = get_current_user_id();
}
$lesson_ids = $woothemes_sensei->post_types->course->course_lessons($course_id, 'any', 'ids');
foreach ($lesson_ids as $lesson_id) {
WooThemes_Sensei_Utils::sensei_remove_user_from_lesson($lesson_id, $user_id, true);
}
// Delete course status
$args = array('post_id' => $course_id, 'type' => 'sensei_course_status', 'user_id' => $user_id);
WooThemes_Sensei_Utils::sensei_delete_activities($args);
do_action('sensei_user_course_reset', $user_id, $course_id);
return true;
}
示例3: sensei_complete_lesson
public function sensei_complete_lesson()
{
// echo "lesson complete task <br>";
global $post, $woothemes_sensei, $current_user;
// Handle Quiz Completion
if (isset($_POST['quiz_complete']) && wp_verify_nonce($_POST['woothemes_sensei_complete_lesson_noonce'], 'woothemes_sensei_complete_lesson_noonce')) {
$sanitized_submit = esc_html($_POST['quiz_complete']);
switch ($sanitized_submit) {
case apply_filters('sensei_complete_lesson_text', __('Complete Lesson', 'woothemes-sensei')):
WooThemes_Sensei_Utils::sensei_start_lesson($post->ID, $current_user->ID, $complete = true);
break;
case apply_filters('sensei_reset_lesson_text', __('Reset Lesson', 'woothemes-sensei')):
WooThemes_Sensei_Utils::sensei_remove_user_from_lesson($post->ID, $current_user->ID);
$this->messages = '<div class="sensei-message note">' . apply_filters('sensei_lesson_reset_text', __('Lesson Reset Successfully.', 'woothemes-sensei')) . '</div>';
break;
default:
// Nothing
break;
}
// End Switch Statement
}
// End If Statement
}
示例4: remove_user_from_post
public function remove_user_from_post()
{
global $woothemes_sensei;
$return = '';
// Security check
$nonce = '';
if (isset($_POST['remove_user_from_post_nonce'])) {
$nonce = esc_html($_POST['remove_user_from_post_nonce']);
}
if (!wp_verify_nonce($nonce, 'remove_user_from_post_nonce')) {
die($return);
}
// Parse POST data
$data = $_POST['data'];
$action_data = array();
parse_str($data, $action_data);
if ($action_data['user_id'] && $action_data['post_id'] && $action_data['post_type']) {
$user_id = intval($action_data['user_id']);
$post_id = intval($action_data['post_id']);
$post_type = sanitize_text_field($action_data['post_type']);
$user = get_userdata($user_id);
switch ($post_type) {
case 'course':
$removed = WooThemes_Sensei_Utils::sensei_remove_user_from_course($post_id, $user_id);
do_action('sensei_user_course_reset', $user_id, $post_id);
break;
case 'lesson':
$removed = WooThemes_Sensei_Utils::sensei_remove_user_from_lesson($post_id, $user_id);
do_action('sensei_user_lesson_reset', $user_id, $post_id);
break;
}
if ($removed) {
$return = 'removed';
}
}
die($return);
}