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


PHP learn_press_get_current_user函数代码示例

本文整理汇总了PHP中learn_press_get_current_user函数的典型用法代码示例。如果您正苦于以下问题:PHP learn_press_get_current_user函数的具体用法?PHP learn_press_get_current_user怎么用?PHP learn_press_get_current_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了learn_press_get_current_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_request_url

 function get_request_url($order_id)
 {
     $user = learn_press_get_current_user();
     $nonce = wp_create_nonce('learn-press-paypal-nonce');
     $order = LP_Order::instance($order_id);
     $custom = array('order_id' => $order_id, 'order_key' => $order->order_key);
     $query = array('cmd' => '_xclick', 'amount' => learn_press_get_cart_total(), 'quantity' => '1', 'business' => $this->paypal_email, 'item_name' => learn_press_get_cart_description(), 'return' => add_query_arg(array('learn-press-transaction-method' => 'paypal-standard', 'paypal-nonce' => $nonce), learn_press_get_cart_course_url()), 'currency_code' => learn_press_get_currency(), 'notify_url' => get_site_url() . '/?' . learn_press_get_web_hook('paypal-standard') . '=1', 'no_note' => '1', 'shipping' => '0', 'email' => $user->user_email, 'rm' => '2', 'cancel_return' => learn_press_get_cart_course_url(), 'custom' => json_encode($custom), 'no_shipping' => '1');
     $query = apply_filters('learn_press_paypal_standard_query', $query);
     $paypal_payment_url = $this->paypal_url . '?' . http_build_query($query);
     return $paypal_payment_url;
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:11,代码来源:class-lp-gateway-paypal-basic.php

示例2: learn_press_user_prerequisite_courses

/**
 * Get all prerequisite courses that user need to pass before take a course
 *
 * @param bool $user_id
 * @param      $course_id -=90a4
 *
 * @return array|bool
 */
function learn_press_user_prerequisite_courses($user_id = false, $course_id)
{
    if (!$user_id) {
        $user = learn_press_get_current_user();
        $user_id = $user->ID;
    }
    $prerequisite = (array) get_post_meta($course_id, '_lpr_course_prerequisite', true);
    $courses = false;
    if ($prerequisite) {
        $course_completed = get_user_meta($user_id, '_lpr_course_completed', true);
        foreach ($prerequisite as $course) {
            if ($course && $course_completed) {
                if (!array_key_exists($course, $course_completed)) {
                    if (!$courses) {
                        $courses = array();
                    }
                    $courses[] = $course;
                }
            }
        }
    }
    return $courses;
}
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:31,代码来源:lp-user-functions.php

示例3: learn_press_get_user_course_status

 * Template for displaying the enroll button
 *
 * @author  ThimPress
 * @package LearnPress/Templates
 * @version 1.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
global $course;
if (!$course->is_required_enroll()) {
    return;
}
$course_status = learn_press_get_user_course_status();
$user = learn_press_get_current_user();
// only show enroll button if user had not enrolled
$purchase_button_text = apply_filters('learn_press_purchase_button_text', __('Buy this course', 'learn_press'));
$enroll_button_text = apply_filters('learn_press_enroll_button_loading_text', __('Enroll', 'learn_press'));
if ($user->has('enrolled-course', $course->id)) {
    ?>

	<?php 
    learn_press_display_message(__('You have already enrolled this course', 'learn_press'));
    ?>

<?php 
} else {
    ?>
	<?php 
    if ($user->has('purchased-course', $course->id)) {
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:31,代码来源:enroll-button.php

示例4: post_review_message_box

        /**
         * Log the messages between admin and instructor
         */
        function post_review_message_box()
        {
            global $post;
            if (!learn_press_course_is_required_review($post->ID, get_current_user_id())) {
                //return;
            }
            $user = learn_press_get_current_user();
            if ($user->is_instructor()) {
                ?>
				<div id="learn-press-review-message">
					<h4><?php 
                _e('Your message to Reviewer', 'learn_press');
                ?>
</h4>
					<textarea name="review_message" resize="none" placeholder="<?php 
                _e('Enter some information here for reviewer', 'learn_press');
                ?>
"></textarea>
					<p>
						<label>
							<input type="checkbox" />
							<?php 
                _e('Notice to the admin for reviews', 'learn_press');
                ?>
						</label>
					</p>
					<p class="description submitdelete">
						<?php 
                _e('Warning! Your course will become to Pending Review for admin reviews before it can be published when you update');
                ?>
					</p>
				</div>
				<?php 
                ob_start();
                ?>
				<script type="text/javascript">
					$('#post').submit(function (e) {
						var $review = $('textarea[name="review_message"]');
						if (!($review.val() + '').length) {
							alert('<?php 
                _e('Please write your message to Reviewer', 'learn_press');
                ?>
');
							$review.focus();
							return false;
						}
					});
				</script>
				<?php 
                learn_press_enqueue_script(strip_tags(ob_get_clean()));
                ?>
				<?php 
            } else {
                if ($user->is_admin()) {
                    ?>
				<div id="learn-press-review-message">
					<h4><?php 
                    _e('Your message to Instructor', 'learn_press');
                    ?>
</h4>
					<textarea name="review_message" resize="none" placeholder="<?php 
                    _e('Enter some information here for instructor. E.g: for reason why the course is rejected etc...', 'learn_press');
                    ?>
"></textarea>
					<p>
						<label>
							<input type="checkbox" />
							<?php 
                    _e('Notice to the instructor for changes', 'learn_press');
                    ?>
						</label>
					</p>
				</div>
				<?php 
                    ob_start();
                    ?>
				<script type="text/javascript">
					$('#post').submit(function (e) {
						var $review = $('textarea[name="review_message"]', this),
							$status = $('select#post_status', this),
							clicked = $(':focus', this).attr('name');
						if (clicked == 'save' && $status.val() != 'publish' && !($review.val() + '').length) {
							alert('<?php 
                    _e('Please write your message to Reviewer', 'learn_press');
                    ?>
');
							$review.focus();
							return false;
						}
					});
				</script>
				<?php 
                    learn_press_enqueue_script(strip_tags(ob_get_clean()));
                    ?>
				<?php 
                }
            }
//.........这里部分代码省略.........
开发者ID:thonysmith,项目名称:LearnPress,代码行数:101,代码来源:course.php

示例5: learn_press_take_course

/**
 * Action when user press the "Take this course" button
 *
 * @param $course_id
 * @param string $payment_method
 */
function learn_press_take_course($course_id, $payment_method = '')
{
    $user = learn_press_get_current_user();
    $can_take_course = apply_filters('learn_press_before_take_course', true, $user->ID, $course_id, $payment_method);
    if ($can_take_course) {
        if (learn_press_is_free_course($course_id)) {
            if ($order_id = learn_press_add_transaction(array('method' => 'free', 'method_id' => '', 'status' => '', 'user_id' => $user->ID, 'transaction_object' => learn_press_generate_transaction_object()))) {
                learn_press_update_order_status($order_id, 'Completed');
                learn_press_add_message('message', __('Congratulations! You have enrolled this course'));
                $json = array('result' => 'success', 'redirect' => ($confirm_page_id = learn_press_get_page_id('taken_course_confirm')) && get_post($confirm_page_id) ? learn_press_get_order_confirm_url($order_id) : get_permalink($course_id));
                learn_press_send_json($json);
            }
        } else {
            if (has_filter('learn_press_take_course_' . $payment_method)) {
                $order = null;
                $result = apply_filters('learn_press_take_course_' . $payment_method, $order);
                $result = apply_filters('learn_press_payment_result', $result, $order);
                if (is_ajax()) {
                    learn_press_send_json($result);
                    exit;
                } else {
                    wp_redirect($result['redirect']);
                    exit;
                }
            } else {
                wp_die(__('Invalid payment method.', 'learn_press'));
            }
        }
    } else {
        learn_press_add_message('error', __('Sorry! You can not enroll to this course'));
        $json = array('result' => 'error', 'redirect' => get_permalink($course_id));
        echo '<!--LPR_START-->' . json_encode($json) . '<!--LPR_END-->';
    }
}
开发者ID:arshanam,项目名称:LearnPress,代码行数:40,代码来源:lpr-course-functions.php

示例6: learn_press_add_order

/**
 * @param null $args
 *
 * @return mixed
 */
function learn_press_add_order($args = null)
{
    //$method, $method_id, $status = 'Pending', $customer_id = false, $transaction_object = false, $args = array()
    $default_args = array('method' => '', 'method_id' => '', 'status' => '', 'user_id' => null, 'order_id' => 0, 'parent' => 0, 'transaction_object' => false);
    $args = wp_parse_args($args, $default_args);
    $order_data = array();
    if ($args['order_id'] > 0 && get_post($args['order_id'])) {
        $updating = true;
        $order_data['ID'] = $args['order_id'];
    } else {
        $updating = false;
        $order_data['post_type'] = LP()->order_post_type;
        $order_data['post_status'] = !empty($args['status']) ? 'publish' : 'lpr-draft';
        $order_data['ping_status'] = 'closed';
        $order_data['post_author'] = ($order_owner_id = learn_press_cart_order_instructor()) ? $order_owner_id : 1;
        // always is administrator
        $order_data['post_parent'] = absint($args['parent']);
    }
    $order_title = array();
    if ($args['method']) {
        $order_title[] = $args['method'];
    }
    if ($args['method_id']) {
        $order_title[] = $args['method_id'];
    }
    $order_title[] = date_i18n('Y-m-d-H:i:s');
    $order_data['post_title'] = join('-', $order_title);
    if (empty($args['user_id'])) {
        $user = learn_press_get_current_user();
        $args['user_id'] = $user->ID;
    }
    if (!$args['transaction_object']) {
        $args['transaction_object'] = learn_press_generate_transaction_object();
    }
    if (!$updating) {
        if ($transaction_id = wp_insert_post($order_data)) {
            update_post_meta($transaction_id, '_learn_press_transaction_method', $args['method']);
            //update_post_meta( $transaction_id, '_learn_press_transaction_status',    $status );
            update_post_meta($transaction_id, '_learn_press_customer_id', $args['user_id']);
            update_post_meta($transaction_id, '_learn_press_customer_ip', learn_press_get_ip());
            update_post_meta($transaction_id, '_learn_press_order_items', $args['transaction_object']);
            add_user_meta($args['user_id'], '_lpr_order_id', $transaction_id);
        }
    } else {
        $transaction_id = wp_update_post($order_data);
    }
    if ($transaction_id) {
        if (!empty($args['status'])) {
            learn_press_update_order_status($transaction_id, $args['status']);
        }
        update_post_meta($transaction_id, '_learn_press_transaction_method_id', $args['method_id']);
        if ($args['transaction_object']) {
            update_post_meta($transaction_id, '_learn_press_order_items', $args['transaction_object']);
        }
        if (!empty($args['status'])) {
            if ($updating) {
                return apply_filters('learn_press_update_transaction_success', $transaction_id, $args);
            } else {
                return apply_filters('learn_press_add_transaction_success', $transaction_id, $args);
            }
        }
        return $transaction_id;
    }
    return false;
    //do_action( 'learn_press_add_transaction_fail', $args );// $method, $method_id, $status, $customer_id, $transaction_object, $args );
}
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:71,代码来源:lp-order-functions.php

示例7: learn_press_redirect_to_question

/**
 * Redirect to question if user access to a quiz that user has started
 *
 * @param string
 *
 * @return string
 */
function learn_press_redirect_to_question($template)
{
    global $post_type;
    if (is_single() && $post_type == LP()->quiz_post_type) {
        $user = learn_press_get_current_user();
        $quiz_id = get_the_ID();
        $quiz_status = $user->get_quiz_status($quiz_id);
        if ($quiz_status == 'started' && learn_press_get_quiz_time_remaining($user->id, $quiz_id) == 0 && get_post_meta($quiz_id, '_lpr_duration', true)) {
            $user->finish_quiz($quiz_id);
            $quiz_status = 'completed';
        }
        if (learn_press_get_request('question') && $quiz_status == '') {
            wp_redirect(get_the_permalink($quiz_id));
        } elseif ($quiz_status == 'started') {
            if (learn_press_get_request('question')) {
            } else {
                wp_redirect(learn_press_get_user_question_url($quiz_id));
                die;
            }
        } elseif ($quiz_status == 'completed' && learn_press_get_request('question')) {
            wp_redirect(get_the_permalink($quiz_id));
            die;
        }
    }
    return $template;
}
开发者ID:thonysmith,项目名称:LearnPress,代码行数:33,代码来源:lp-quiz-functions.php

示例8:

<?php

if (learn_press_get_current_user()->is('guest')) {
    return;
}
$course_id = learn_press_get_course_by_quiz(get_the_ID());
$passed = learn_press_user_has_passed_course($course_id);
$result = learn_press_get_quiz_result();
?>
	<div class="clearfix"></div>
<?php 
if ($passed) {
    ?>
	<?php 
    learn_press_message(sprintf(__('You have passed this course with %.2f%% of total', 'learn_press'), $result['mark_percent'] * 100));
} else {
    ?>
	<?php 
    $passing_condition = learn_press_get_course_passing_condition($course_id);
    ?>
	<?php 
    learn_press_message(sprintf(__('Sorry, you have not passed this course. This course required you pass %.2f%% but your result is only %.2f%%', 'learn_press'), $passing_condition, $result['mark_percent'] * 100), 'error');
}
开发者ID:shrimp2t,项目名称:LearnPress,代码行数:23,代码来源:percentage.php

示例9: save_user_answer

 function save_user_answer($answer, $quiz_id, $user_id = null)
 {
     if ($user_id) {
         $user = LP_User::get_user($user_id);
     } else {
         $user = learn_press_get_current_user();
     }
     if ($progress = $user->get_quiz_progress($quiz_id)) {
         if (!isset($progress->question_answers)) {
             $question_answers = array();
         } else {
             $question_answers = $progress->question_answers;
         }
         $question_answers[$this->id] = $answer;
         $question_answers = apply_filters('learn_press_update_user_question_answers', $question_answers, $progress->history_id, $user_id, $this, $quiz_id);
         learn_press_update_user_quiz_meta($progress->history_id, 'question_answers', $question_answers);
     }
     //do_action( 'learn_press_update_user_answer', $progress, $user_id, $this, $quiz_id );
 }
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:19,代码来源:abstract-lp-question.php

示例10: search_questions

        static function search_questions()
        {
            global $wpdb;
            $quiz_id = learn_press_get_request('quiz_id');
            $user = learn_press_get_current_user();
            if (!$user->is_admin() && get_post_field('post_author', $quiz_id) != get_current_user_id()) {
                wp_die(__('You have not permission to access this section', 'learn_press'));
            }
            $term = (string) stripslashes(learn_press_get_request('term'));
            $exclude = array();
            if (!empty($_GET['exclude'])) {
                $exclude = array_map('intval', $_GET['exclude']);
            }
            $added = $wpdb->get_col($wpdb->prepare("\n\t\t\t\t\tSELECT question_id\n\t\t\t\t\tFROM {$wpdb->prefix}learnpress_quiz_questions\n\t\t\t\t\tWHERE %d\n\t\t\t\t", 1));
            if ($added) {
                $exclude = array_merge($exclude, $added);
                $exclude = array_unique($exclude);
            }
            $args = array('post_type' => array('lp_question'), 'posts_per_page' => -1, 'post_status' => 'publish', 'order' => 'ASC', 'orderby' => 'parent title', 'exclude' => $exclude);
            if (!$user->is_admin()) {
                $args['author'] = $user->id;
            }
            if ($term) {
                $args['s'] = $term;
            }
            $posts = get_posts($args);
            $found_questions = array();
            if (!empty($posts)) {
                foreach ($posts as $post) {
                    $found_questions[$post->ID] = !empty($post->post_title) ? $post->post_title : sprintf('(%s)', __('Untitled', 'learn_press'));
                }
            }
            ob_start();
            if ($found_questions) {
                foreach ($found_questions as $id => $question) {
                    printf('
						<li class="" data-id="%1$d" data-type="" data-text="%2$s">
						<label>
							<input type="checkbox" value="%1$d">
							<span class="lp-item-text">%2$s</span>
						</label>
					</li>
					', $id, $question);
                }
            } else {
                echo '<li>' . __('No question found', 'learn_press') . '</li>';
            }
            $response = array('html' => ob_get_clean(), 'data' => $found_questions, 'args' => $args);
            learn_press_send_json($response);
        }
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:50,代码来源:class-lp-admin-ajax.php

示例11: start_quiz

 function start_quiz()
 {
     $quiz_id = !empty($_REQUEST['quiz_id']) ? absint($_REQUEST['quiz_id']) : 0;
     if (!$quiz_id) {
         learn_press_send_json(array('result' => 'error', 'message' => __('The quiz ID is empty', 'learn_press')));
     }
     $quiz = LP_Quiz::get_quiz($quiz_id);
     if (!$quiz->id || $quiz->id != $quiz_id) {
         learn_press_send_json(array('result' => 'error', 'message' => __('Something is wrong! Please try again', 'learn_press')));
     }
     $user = learn_press_get_current_user();
     if ($quiz->is_require_enrollment() && $user->is('guest')) {
         learn_press_send_json(array('result' => 'error', 'message' => __('Please login to do this quiz', 'learn_press')));
     }
     $user->set_quiz($quiz);
     switch (strtolower($user->get_quiz_status())) {
         case 'completed':
             learn_press_send_json(array('result' => 'error', 'message' => __('You have completed this quiz', 'learn_press'), 'data' => $user->get_quiz_result()));
             break;
         case 'started':
             learn_press_send_json(array('result' => 'error', 'message' => __('You have started this quiz', 'learn_press'), 'data' => array('status' => $user->get_quiz_status())));
             break;
         default:
             $result = $user->start_quiz();
             learn_press_send_json(array('result' => 'success', 'data' => $result, 'question_url' => learn_press_get_user_question_url($quiz_id), 'question_content' => $user->get_current_question($quiz_id, 'html')));
     }
     die;
 }
开发者ID:shrimp2t,项目名称:LearnPress,代码行数:28,代码来源:class.lpr-ajax.php

示例12: get_paypal_basic_request_url

 function get_paypal_basic_request_url($order)
 {
     $settings = get_option('_lpr_settings_payment');
     if (empty($settings['paypal'])) {
         return;
     }
     $paypal_settings = $settings['paypal'];
     $user = learn_press_get_current_user();
     $paypal_args = array('cmd' => '_xclick', 'amount' => learn_press_get_cart_total(), 'quantity' => '1');
     $transaction = learn_press_generate_transaction_object();
     $temp_id = learn_press_uniqid();
     $xxx = @file_get_contents(LPR_PLUGIN_PATH . '/temp.txt');
     learn_press_set_transient_transaction('lpps', $temp_id, $user->ID, $transaction);
     file_put_contents(LPR_PLUGIN_PATH . '/temp.txt', $xxx . "=" . $temp_id);
     /*$order_id = LearnPress()->session->get( 'learn_press_user_order' );
     
             $order_id = learn_press_add_transaction(
                 array(
                     'method'        => $this->method,
                     'method_id'     => '',
                     'status'        => '',
                     'user_id'       => null,
                     'order_id'      => $order_id,
                     'parent'        => 0,
                     'transaction_object' => $transaction
                 )
             );
     
             //LearnPress()->session->set( 'learn_press_user_order', $order_id );
     
             $order = new LPR_Order( $order_id );*/
     $nonce = wp_create_nonce('learn-press-paypal-nonce');
     $paypal_email = $paypal_settings['sandbox'] ? $paypal_settings['paypal_sandbox_email'] : $paypal_settings['paypal_email'];
     $query = array('business' => $paypal_email, 'item_name' => learn_press_get_cart_description(), 'return' => add_query_arg(array('learn-press-transaction-method' => 'paypal-standard', 'paypal-nonce' => $nonce), learn_press_get_cart_course_url()), 'currency_code' => learn_press_get_currency(), 'notify_url' => get_site_url() . '/?' . learn_press_get_web_hook('paypal-standard') . '=1', 'no_note' => '1', 'shipping' => '0', 'email' => $user->user_email, 'rm' => '2', 'cancel_return' => learn_press_get_cart_course_url(), 'custom' => $temp_id, 'no_shipping' => '1');
     $query = array_merge($paypal_args, $query);
     $query = apply_filters('it_exchange_paypal_standard_query', $query);
     $paypal_payment_url = ($paypal_settings['sandbox'] ? $this->paypal_payment_sandbox_url : $this->paypal_payment_live_url) . '?' . http_build_query($query);
     return $paypal_payment_url;
 }
开发者ID:arshanam,项目名称:LearnPress,代码行数:39,代码来源:class.lpr-gateway-paypal.php

示例13: get_paypal_args

 function get_paypal_args($order)
 {
     $this->prepare_line_items();
     $user = learn_press_get_current_user();
     $nonce = wp_create_nonce('learn-press-paypal-nonce');
     $custom = array('order_id' => $order->id, 'order_key' => $order->order_key);
     $args = array_merge(array('cmd' => '_cart', 'business' => $this->paypal_email, 'no_note' => 1, 'currency_code' => learn_press_get_currency(), 'charset' => 'utf-8', 'rm' => is_ssl() ? 2 : 1, 'upload' => 1, 'return' => esc_url($this->get_return_url($order)), 'cancel_return' => esc_url(learn_press_is_enable_cart() ? learn_press_get_page_link('cart') : get_site_url()), 'bn' => 'LearnPress_Cart', 'custom' => json_encode($custom), 'notify_url' => get_site_url() . '/?' . learn_press_get_web_hook('paypal') . '=1', 'email' => $user->user_email), $this->get_item_lines());
     //print_r($args);die();
     return apply_filters('learn_press_paypal_args', $args);
 }
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:10,代码来源:class-lp-gateway-paypal.php

示例14: learn_press_get_passed_courses

/**
 * @param $user_id
 *
 * @return WP_Query
 */
function learn_press_get_passed_courses($user_id)
{
    $user = learn_press_get_current_user();
    return $user->get_finished_courses();
    $pid = get_user_meta($user_id, '_lpr_course_finished', true);
    if (!$pid) {
        $pid = array(0);
    }
    $arr_query = array('post_type' => LP()->course_post_type, 'post__in' => $pid, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'posts_per_page' => -1);
    $my_query = new WP_Query($arr_query);
    return $my_query;
}
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:17,代码来源:lp-core-functions.php

示例15: get_view_order_url

 function get_view_order_url()
 {
     global $wp_query;
     $view_order_url = learn_press_get_endpoint_url('view-order', $this->id, learn_press_get_page_link('profile'));
     //
     $user = learn_press_get_current_user();
     $view_order_endpoint = LP()->settings->get('profile_endpoints.profile-order-details');
     if (!$view_order_endpoint) {
         $view_order_endpoint = 'order-details';
     }
     if (get_option('permalink_structure')) {
         $view_order_url = learn_press_get_page_link('profile') . $user->user_login . '/' . $view_order_endpoint . '/' . $this->id;
     } else {
         $args = array('user' => $user->user_login);
         $args['view'] = $view_order_endpoint;
         if ($view_order_endpoint) {
             $args['id'] = $this->id;
         }
         $view_order_url = add_query_arg($args, learn_press_get_page_link('profile'));
     }
     return apply_filters('learn_press_view_order_url', $view_order_url, $this);
 }
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:22,代码来源:class-lp-order.php


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