當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WooThemes_Sensei_Utils::sensei_remove_user_from_course方法代碼示例

本文整理匯總了PHP中WooThemes_Sensei_Utils::sensei_remove_user_from_course方法的典型用法代碼示例。如果您正苦於以下問題:PHP WooThemes_Sensei_Utils::sensei_remove_user_from_course方法的具體用法?PHP WooThemes_Sensei_Utils::sensei_remove_user_from_course怎麽用?PHP WooThemes_Sensei_Utils::sensei_remove_user_from_course使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WooThemes_Sensei_Utils的用法示例。


在下文中一共展示了WooThemes_Sensei_Utils::sensei_remove_user_from_course方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sensei_woocommerce_cancel_order

 /**
  * Runs when an order is cancelled.
  * @since   1.2.0
  * @access  public
  * @param   integer $order_id order ID
  * @return  void
  */
 public function sensei_woocommerce_cancel_order($order_id)
 {
     // Get order object
     $order = new WC_Order($order_id);
     // Run through each product ordered
     if (0 < sizeof($order->get_items())) {
         // Get order user
         $user_id = $order->__get('user_id');
         foreach ($order->get_items() as $item) {
             $product_type = '';
             if (isset($item['variation_id']) && 0 < $item['variation_id']) {
                 $item_id = $item['variation_id'];
                 $product_type = 'variation';
             } else {
                 $item_id = $item['product_id'];
             }
             // End If Statement
             $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type);
             // Get courses that use the WC product
             $courses = array();
             $courses = $this->post_types->course->get_product_courses($item_id);
             // Loop and update those courses
             foreach ($courses as $course_item) {
                 // Check and Remove course from courses user meta
                 $dataset_changes = WooThemes_Sensei_Utils::sensei_remove_user_from_course($course_item->ID, $user_id);
             }
             // End For Loop
         }
         // End For Loop
     }
     // End If Statement
 }
開發者ID:drumchannel,項目名稱:drumchannel-dev,代碼行數:39,代碼來源:class-woothemes-sensei.php

示例2: remove_active_course

 /**
  * Remove active course when an order is refunded or cancelled
  * @param  integer $order_id ID of order
  * @return void
  */
 public function remove_active_course($order_id)
 {
     $order = new WC_Order($order_id);
     foreach ($order->get_items() as $item) {
         if ($item['product_id'] > 0) {
             $user_id = get_post_meta($order_id, '_customer_user', true);
             if ($user_id) {
                 // Get all courses for product
                 $args = array('posts_per_page' => -1, 'post_type' => 'course', 'meta_query' => array(array('key' => '_course_woocommerce_product', 'value' => $item['product_id'])), 'orderby' => 'menu_order date', 'order' => 'ASC', 'fields' => 'ids');
                 $course_ids = get_posts($args);
                 if ($course_ids && count($course_ids) > 0) {
                     foreach ($course_ids as $course_id) {
                         // Remove all course user meta
                         WooThemes_Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id);
                     }
                     // End For Loop
                 }
                 // End If Statement
             }
             // End If Statement
         }
         // End If Statement
     }
     // End For Loop
 }
開發者ID:Ezyva2015,項目名稱:opendooronline.com.au,代碼行數:30,代碼來源:class-woothemes-sensei-frontend.php

示例3: 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);
 }
開發者ID:RiaanKnoetze,項目名稱:sensei,代碼行數:42,代碼來源:class-woothemes-sensei-learners.php

示例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);
 }
開發者ID:AlecBeltrami,項目名稱:sensei,代碼行數:37,代碼來源:class-woothemes-sensei-learners.php


注:本文中的WooThemes_Sensei_Utils::sensei_remove_user_from_course方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。