当前位置: 首页>>代码示例>>PHP>>正文


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怎么用?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;
 }
开发者ID:RiaanKnoetze,项目名称:sensei,代码行数:57,代码来源:class-woothemes-sensei-learners.php

示例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);
         }
     }
 }
开发者ID:mattytemple,项目名称:YTC-Sensei,代码行数:16,代码来源:class-woothemes-sensei-course.php


注:本文中的WooThemes_Sensei_Utils::user_complete_course方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。