本文整理汇总了PHP中WooThemes_Sensei_Utils::user_complete_course方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::user_complete_course方法的具体用法?PHP WooThemes_Sensei_Utils::user_complete_course怎么用?PHP WooThemes_Sensei_Utils::user_complete_course使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WooThemes_Sensei_Utils
的用法示例。
在下文中一共展示了WooThemes_Sensei_Utils::user_complete_course方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_new_learners
public function add_new_learners()
{
$result = false;
if (!isset($_POST['add_learner_submit'])) {
return $result;
}
if (!isset($_POST['add_learner_nonce']) || !wp_verify_nonce($_POST['add_learner_nonce'], 'add_learner_to_sensei')) {
return $result;
}
if (!isset($_POST['add_user_id']) || '' == $_POST['add_user_id'] || !isset($_POST['add_post_type']) || !isset($_POST['add_course_id']) || !isset($_POST['add_lesson_id'])) {
return $result;
}
$post_type = $_POST['add_post_type'];
$user_id = absint($_POST['add_user_id']);
$course_id = absint($_POST['add_course_id']);
switch ($post_type) {
case 'course':
$result = WooThemes_Sensei_Utils::user_start_course($user_id, $course_id);
// Complete each lesson if course is set to be completed
if (isset($_POST['add_complete_course']) && 'yes' == $_POST['add_complete_course']) {
$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
foreach ($lesson_ids as $id) {
WooThemes_Sensei_Utils::sensei_start_lesson($id, $user_id, true);
}
// Updates the Course status and it's meta data
WooThemes_Sensei_Utils::user_complete_course($course_id, $user_id);
do_action('sensei_user_course_end', $user_id, $course_id);
}
break;
case 'lesson':
$lesson_id = absint($_POST['add_lesson_id']);
$complete = false;
if (isset($_POST['add_complete_lesson']) && 'yes' == $_POST['add_complete_lesson']) {
$complete = true;
}
$result = WooThemes_Sensei_Utils::sensei_start_lesson($lesson_id, $user_id, $complete);
// Updates the Course status and it's meta data
WooThemes_Sensei_Utils::user_complete_course($course_id, $user_id);
break;
}
// Set redirect URL after adding user to course/lesson
$query_args = array('page' => $this->page_slug, 'view' => 'learners');
if ($result) {
if ($course_id) {
$query_args['course_id'] = $course_id;
}
if ($lesson_id) {
$query_args['lesson_id'] = $lesson_id;
}
$query_args['message'] = 'success';
} else {
$query_args['message'] = 'error';
}
$redirect_url = apply_filters('sensei_learners_add_learner_redirect_url', add_query_arg($query_args, admin_url('admin.php')));
wp_safe_redirect(esc_url_raw($redirect_url));
exit;
}
示例2: update_status_after_lesson_change
/**
* Fires when a lesson has changed to check if the Course status needs changing
*
* @param int $user_id
* @param int $lesson_id
*/
public function update_status_after_lesson_change($user_id, $lesson_id)
{
if (intval($user_id) > 0 && intval($lesson_id) > 0) {
$course_id = get_post_meta($lesson_id, '_lesson_course', true);
if (intval($course_id) > 0) {
// Updates the Course status and it's meta data
WooThemes_Sensei_Utils::user_complete_course($course_id, $user_id);
}
}
}