本文整理汇总了PHP中WooThemes_Sensei_Utils::user_started_course方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::user_started_course方法的具体用法?PHP WooThemes_Sensei_Utils::user_started_course怎么用?PHP WooThemes_Sensei_Utils::user_started_course使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WooThemes_Sensei_Utils
的用法示例。
在下文中一共展示了WooThemes_Sensei_Utils::user_started_course方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: single_lesson_handler
public function single_lesson_handler()
{
global $post;
// Preview Lessons shouldn't ignore this rule.
if (WooThemes_Sensei_Utils::is_preview_lesson($post->ID)) {
return;
}
$course_id = get_post_meta($post->ID, '_lesson_course', true);
// User already started this course, so ideally, we shouldn't restrict access.
if (WooThemes_Sensei_Utils::user_started_course($post->ID, wp_get_current_user()->ID)) {
return;
}
// This happens if the lesson isn't locked itself.
if (memberful_can_user_access_post(wp_get_current_user()->ID, $post->ID)) {
if (!memberful_can_user_access_post(wp_get_current_user()->ID, $course_id)) {
// The user doesn't have access to this post, so he shouldn't have actions on it.
remove_all_actions('sensei_lesson_single_meta');
// Now the funky filtering part.
remove_action('the_content', 'memberful_wp_protect_content');
add_action('the_content', array($this, 'single_lesson_special_content_filter'), -10);
}
} else {
// The user doesn't have access to this post, so he shouldn't have actions on it.
remove_all_actions('sensei_lesson_single_meta');
}
}
示例2: setup_course_query
/**
* Sets up the object course query
* that will be used int he render method.
*
* @since 1.9.0
*/
protected function setup_course_query()
{
// course query parameters to be used for all courses
$query_args = array('post_type' => 'course', 'post_status' => 'publish', 'posts_per_page' => 1000, 'orderby' => $this->orderby, 'order' => $this->order);
// get all the courses that has a product attached
$all_courses_query = new WP_Query($query_args);
$paid_courses_not_taken = array();
// look through all course and find the purchasable ones that user has not purchased
foreach ($all_courses_query->posts as $course) {
// only keep the courses with a product including only courses that the user not taking
$course_product_id = get_post_meta($course->ID, '_course_woocommerce_product', true);
if (is_numeric($course_product_id) && !WooThemes_Sensei_Utils::user_started_course($course->ID, get_current_user_id())) {
$paid_courses_not_taken[] = $course->ID;
}
}
// end foreach
// setup the course query again and only use the course the user has not purchased.
// this query will be loaded into the global WP_Query in the render function.
$query_args['post__in'] = $paid_courses_not_taken;
$query_args['posts_per_page'] = $this->number;
$this->query = new WP_Query($query_args);
}
示例3: get_currentuserinfo
}
global $post, $woothemes_sensei, $current_user;
// Get User Meta
get_currentuserinfo();
// Handle Quiz Completion
do_action('sensei_complete_quiz');
// Get Frontend data
$user_quiz_grade = $woothemes_sensei->quiz->data->user_quiz_grade;
$quiz_lesson = $woothemes_sensei->quiz->data->quiz_lesson;
$quiz_grade_type = $woothemes_sensei->quiz->data->quiz_grade_type;
$user_lesson_end = $woothemes_sensei->quiz->data->user_lesson_end;
$user_lesson_complete = $woothemes_sensei->quiz->data->user_lesson_complete;
$lesson_quiz_questions = $woothemes_sensei->quiz->data->lesson_quiz_questions;
// Check if the user has started the course
$lesson_course_id = absint(get_post_meta($quiz_lesson, '_lesson_course', true));
$has_user_start_the_course = WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID);
// Get the meta info
$quiz_passmark = absint(get_post_meta($post->ID, '_quiz_passmark', true));
$quiz_passmark_float = (double) $quiz_passmark;
?>
<div class="lesson-meta">
<?php
// Display user's quiz status
$status = WooThemes_Sensei_Utils::sensei_user_quiz_status_message($quiz_lesson, $current_user->ID);
echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
// Lesson Quiz Meta
if (0 < count($lesson_quiz_questions)) {
$question_count = 1;
?>
<form method="POST" action="<?php
echo esc_url(get_permalink());
示例4: savedquest_options
//.........这里部分代码省略.........
echo "(100%)";
}
echo '<br />';
}
// End For Loop
echo "</td>";
echo "<td>";
echo $diftime;
echo "</td>";
echo "</tr>";
//echo $course->post_title." (".$course_status_update['percent'][0]."% Complete) (". $incomplete . "% incomplete) (". $course_user_grade . "% Competent)<br />";
$i++;
}
}
}
echo "</table>";
} elseif ($tab == "threshold") {
//declare the wpdb for custom query
global $wpdb;
//check for submitted data
if (isset($_POST['submittreshold']) && ($_POST['submittreshold'] = "submit")) {
// declare users and variables
$allUsers = get_users();
$modules_completed = $_POST['completionpermonth'];
$courseid = $_POST['course'];
$course_name = get_the_title($courseid);
$array_to_csv = array(array('Student Name', 'Course Name '));
//user loop ----- loop user get the groups and course the course they take
foreach ($allUsers as $user) {
//declare course function calls
$course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->ID);
$user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->ID);
$course_status_info = get_comment_meta($user_course_status->comment_ID);
$started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->ID);
$course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->ID);
$completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
//get the user groups
$useringroup = new Groups_User($user->ID);
$user_groups = $useringroup->__get('groups');
$displayed_lessons = array();
//declare and get module values
$modules = Sensei()->modules->get_course_modules(intval($courseid));
$modules_content = Sensei()->modules->course_module_content(intval($courseid));
//echo "<pre>";
//echo $user->user_email."<br />";
//echo "sensei_user_course_status_message: ";
//print_r($course_status);
//echo "<br />";
//echo "started_course: "."<br />";
$course_status_info['start'][0];
$datenow = date('Y-m-d h:i:s');
$date1 = date_create($course_status_info['start'][0]);
$date2 = date_create($datenow);
$diff = date_diff($date1, $date2);
$diftime = $diff->format("%m");
if ($diftime < 1) {
$diftime = 1;
}
//echo "</pre>";
//module loop per user
foreach ($modules as $module) {
$args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($courseid), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . $module->term_id, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'suppress_filters' => 0);
$lessons = get_posts($args);
$num_of_lesson = count($lessons);
//lessson loop per user
foreach ($lessons as $lesson_item) {
示例5: course_lessons
/**
* Load template for displaying course lessons
* @since 1.4.0
* @return void
*/
public function course_lessons()
{
global $course, $woothemes_sensei, $current_user;
$started_course = WooThemes_Sensei_Utils::user_started_course($course->ID, $current_user->ID);
if ($started_course) {
$woothemes_sensei->frontend->sensei_get_template('course-results/course-lessons.php');
}
}
示例6: do_action
?>
<?php
do_action('sensei_lesson_single_title');
?>
<?php
$view_lesson = true;
wp_get_current_user();
$lesson_prerequisite = absint(get_post_meta($post->ID, '_lesson_prerequisite', true));
if ($lesson_prerequisite > 0) {
// Check for prerequisite lesson completions
$view_lesson = WooThemes_Sensei_Utils::user_completed_lesson($lesson_prerequisite, $current_user->ID);
}
$lesson_course_id = get_post_meta($post->ID, '_lesson_course', true);
$user_taking_course = WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID);
if (current_user_can('administrator')) {
$view_lesson = true;
$user_taking_course = true;
}
$is_preview = false;
if (WooThemes_Sensei_Utils::is_preview_lesson($post->ID)) {
$is_preview = true;
$view_lesson = true;
}
if ($view_lesson) {
?>
<section class="entry fix">
<?php
if ($is_preview && !$user_taking_course) {
示例7: absint
$lesson_course_id = absint(get_post_meta($post->ID, '_lesson_course', true));
$is_preview = WooThemes_Sensei_Utils::is_preview_lesson($post->ID);
// Get User Meta
get_currentuserinfo();
// Complete Lesson Logic
do_action('sensei_complete_lesson');
// Check that the course has been started
if ($woothemes_sensei->access_settings() || WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID) || $is_preview) {
?>
<section class="lesson-meta" id="lesson_complete">
<?php
if (apply_filters('sensei_video_position', 'top', $post->ID) == 'bottom') {
do_action('sensei_lesson_video', $post->ID);
}
?>
<?php
do_action('sensei_frontend_messages');
?>
<?php
if (!$is_preview || WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) {
do_action('sensei_lesson_quiz_meta', $post->ID, $current_user->ID);
}
?>
</section>
<?php
do_action('sensei_lesson_back_link', $lesson_course_id);
} else {
do_action('sensei_lesson_course_signup', $lesson_course_id);
}
// End If Statement
do_action('sensei_lesson_meta_extra', $post->ID);
示例8: sensei_woocommerce_in_cart_message
/**
* This function shows the WooCommerce cart notice if the user has
* added the current course to cart. It does not show if the user is already taking
* the course.
*
* @since 1.0.2
* @return void;
*/
public function sensei_woocommerce_in_cart_message()
{
global $post, $woocommerce;
$wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
$user_course_status_id = WooThemes_Sensei_Utils::user_started_course($post->ID, get_current_user_id());
if (0 < intval($wc_post_id) && !$user_course_status_id) {
if (sensei_check_if_product_is_in_cart($wc_post_id)) {
echo '<div class="sensei-message info">' . sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>');
}
// End If Statement
}
// End If Statement
}
示例9: sensei_course_meta
public function sensei_course_meta()
{
global $woothemes_sensei, $post, $current_user;
?>
<section class="course-meta">
<?php
$is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($post->ID, $current_user->ID);
if (is_user_logged_in() && !$is_user_taking_course) {
// Get the product ID
$wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
// Check for woocommerce
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && 0 < intval($wc_post_id)) {
sensei_wc_add_to_cart($post->ID);
} else {
sensei_start_course_form($post->ID);
}
// End If Statement
} elseif (is_user_logged_in()) {
// Check if course is completed
$user_course_status = WooThemes_Sensei_Utils::user_course_status($post->ID, $current_user->ID);
$completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
// Success message
if ($completed_course) {
?>
<div class="status completed"><?php
echo apply_filters('sensei_complete_text', __('Completed', 'woothemes-sensei'));
?>
</div>
<?php
$has_quizzes = $woothemes_sensei->post_types->course->course_quizzes($post->ID, true);
if (has_filter('sensei_results_links') || $has_quizzes) {
?>
<p class="sensei-results-links">
<?php
$results_link = '';
if ($has_quizzes) {
$results_link = '<a class="view-results" href="' . $woothemes_sensei->course_results->get_permalink($post->ID) . '">' . apply_filters('sensei_view_results_text', __('View results', 'woothemes-sensei')) . '</a>';
}
$results_link = apply_filters('sensei_results_links', $results_link);
echo $results_link;
?>
</p>
<?php
}
?>
<?php
} else {
?>
<div class="status in-progress"><?php
echo apply_filters('sensei_in_progress_text', __('In Progress', 'woothemes-sensei'));
?>
</div>
<?php
}
?>
<?php
} else {
// Get the product ID
$wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
// Check for woocommerce
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && 0 < intval($wc_post_id)) {
sensei_wc_add_to_cart($post->ID);
} else {
// User needs to register
wp_register('<div class="status register">', '</div>');
}
// End If Statement
}
// End If Statement
?>
</section><?php
}
示例10: the_progress_meter
/**
* Output the course progress bar
*
* @param $course_id
* @return void
*/
public function the_progress_meter($course_id = 0, $user_id = 0)
{
if (empty($course_id)) {
global $post;
$course_id = $post->ID;
}
if (empty($user_id)) {
$user_id = get_current_user_id();
}
if ('course' != get_post_type($course_id) || !get_userdata($user_id) || !WooThemes_Sensei_Utils::user_started_course($course_id, $user_id)) {
return;
}
$percentage_completed = $this->get_completion_percentage($course_id, $user_id);
echo $this->get_progress_meter($percentage_completed);
}
示例11: user_start_course
/**
* Start course for user
* @since 1.4.8
* @param integer $user_id User ID
* @param integer $course_id Course ID
* @return mixed boolean or comment_ID
*/
public static function user_start_course($user_id = 0, $course_id = 0)
{
$activity_logged = false;
if ($user_id && $course_id) {
// Check if user is already on the Course
$activity_logged = WooThemes_Sensei_Utils::user_started_course($course_id, $user_id);
if (!$activity_logged) {
// Add user to course
$course_metadata = array('start' => current_time('mysql'), 'percent' => 0, 'complete' => 0);
$activity_logged = WooThemes_Sensei_Utils::update_course_status($user_id, $course_id, $course_status = 'in-progress', $course_metadata);
// Allow further actions
if ($activity_logged) {
do_action('sensei_user_course_start', $user_id, $course_id);
}
}
}
return $activity_logged;
}
示例12: the_course_free_lesson_preview
/**
* Output a link to view course. The button text is different depending on the amount of preview lesson available.
*
* hooked into 'sensei_course_content_inside_after'
*
* @since 1.9.0
*
* @param WP_Post $course
*/
public function the_course_free_lesson_preview($course)
{
// Meta data
$preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course->ID));
$is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($course->ID, get_current_user_id());
if (0 < $preview_lesson_count && !$is_user_taking_course) {
?>
<p class="sensei-free-lessons">
<a href="<?php
echo get_permalink();
?>
">
<?php
_e('Preview this course', 'woothemes-sensei');
?>
</a>
- <?php
echo sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count);
?>
</p>
<?php
}
}
示例13: widget
function widget($args, $instance)
{
global $woothemes_sensei, $post, $current_user, $view_lesson, $user_taking_course;
$allmodules = 'off';
if (isset($instance['allmodules'])) {
$allmodules = $instance['allmodules'];
}
// If not viewing a lesson/quiz, don't display the widget
if (!(is_singular('lesson') || is_singular('quiz'))) {
return;
}
extract($args);
if (is_singular('quiz')) {
$current_lesson_id = absint(get_post_meta($post->ID, '_quiz_lesson', true));
} else {
$current_lesson_id = $post->ID;
}
// get the course for the current lesson/quiz
$lesson_course_id = get_post_meta($current_lesson_id, '_lesson_course', true);
// Check if the user is taking the course
$is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID);
//Check for preview lesson
$is_preview = false;
if (method_exists('WooThemes_Sensei_Utils', 'is_preview_lesson')) {
$is_preview = WooThemes_Sensei_Utils::is_preview_lesson($post->ID);
}
$course_title = get_the_title($lesson_course_id);
$course_url = get_the_permalink($lesson_course_id);
$in_module = false;
$lesson_module = '';
$lesson_array = array();
if (0 < $current_lesson_id) {
// get an array of lessons in the module if there is one
if (isset(Sensei()->modules) && has_term('', Sensei()->modules->taxonomy, $current_lesson_id)) {
// Get all modules
$course_modules = Sensei()->modules->get_course_modules($lesson_course_id);
$lesson_module = Sensei()->modules->get_lesson_module($current_lesson_id);
$in_module = true;
$current_module_title = htmlspecialchars($lesson_module->name);
// Display all modules
if ('on' == $allmodules) {
foreach ($course_modules as $module) {
// get all lessons in the module
$args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($lesson_course_id), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . intval($module->term_id), 'orderby' => 'meta_value_num date', 'order' => 'ASC');
$lesson_array = array_merge($lesson_array, get_posts($args));
}
} else {
// Only display current module
// get all lessons in the current module
$args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($lesson_course_id), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => $lesson_module)), 'meta_key' => '_order_module_' . intval($lesson_module->term_id), 'orderby' => 'meta_value_num date', 'order' => 'ASC');
$lesson_array = get_posts($args);
}
} else {
// if there's no module, get all lessons in the course
$lesson_array = Sensei()->course->course_lessons($lesson_course_id);
}
}
echo $before_widget;
?>
<header>
<h2 class="course-title"><a href="<?php
echo $course_url;
?>
"><?php
echo $course_title;
?>
</a></h2>
<?php
if ($in_module && 'on' != $allmodules) {
?>
<h3 class="module-title"><?php
echo $current_module_title;
?>
</h3>
<?php
}
?>
</header>
<?php
$nav_id_array = sensei_get_prev_next_lessons($current_lesson_id);
$previous_lesson_id = absint($nav_id_array['prev_lesson']);
$next_lesson_id = absint($nav_id_array['next_lesson']);
if (0 < $previous_lesson_id || 0 < $next_lesson_id) {
?>
<ul class="course-progress-navigation">
<?php
if (0 < $previous_lesson_id) {
?>
<li class="prev"><a href="<?php
echo esc_url(get_permalink($previous_lesson_id));
?>
" title="<?php
echo get_the_title($previous_lesson_id);
?>
"><span><?php
//.........这里部分代码省略.........
示例14: Sensei
* Override this template by copying it to yourtheme/sensei/single-course/course-lessons.php
*
* @author WooThemes
* @package Sensei/Templates
* @version 1.0.0
*/
if (!defined('ABSPATH')) {
exit;
}
global $post, $woothemes_sensei, $current_user;
$html = '';
// Get Course Lessons
$course_lessons = Sensei()->course->course_lessons($post->ID);
$total_lessons = count($course_lessons);
// Check if the user is taking the course
$is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($post->ID, $current_user->ID);
// Get User Meta
get_currentuserinfo();
// exit if no lessons exist
if (!($total_lessons > 0)) {
return;
}
$html .= '<section class="course-lessons">';
$html .= '<header>';
$html .= '<h2>' . apply_filters('sensei_lessons_text', __('Lessons', 'woothemes-sensei')) . '</h2>';
$html .= '</header>';
$lesson_count = 1;
$lessons_completed = count(Sensei()->course->get_completed_lesson_ids($post->ID, $current_user->ID));
$show_lesson_numbers = false;
foreach ($course_lessons as $lesson_item) {
//skip lesson that are already in the modules
示例15: sensei_has_user_started_course
function sensei_has_user_started_course($post_id = 0, $user_id = 0)
{
_deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()");
return WooThemes_Sensei_Utils::user_started_course($post_id, $user_id);
}