| @@ -8,9 +8,9 @@ | ||
| 8 | 8 | public function __construct() { |
| 9 | 9 | parent::__construct(); |
| 10 | 10 | |
| 11 | 11 | add_action( 'add_meta_boxes', array($this, 'register_meta_box') ); |
| 12 | - add_action('save_post_'.$this->course_post_type, array($this, 'save_course_meta')); | |
| 12 | + add_action('save_post_'.$this->course_post_type, array($this, 'save_course_meta'), 10, 2); | |
| 13 | 13 | add_action('wp_ajax_tutor_add_course_topic', array($this, 'tutor_add_course_topic')); |
| 14 | 14 | add_action('wp_ajax_tutor_update_topic', array($this, 'tutor_update_topic')); |
| 15 | 15 | |
| 16 | 16 | //Add Column |
| @@ -63,9 +63,9 @@ | ||
| 63 | 63 | * @param $post_ID |
| 64 | 64 | * |
| 65 | 65 | * Insert Topic and attached it with Course |
| 66 | 66 | */ |
| 67 | - public function save_course_meta($post_ID){ | |
| 67 | + public function save_course_meta($post_ID, $post){ | |
| 68 | 68 | global $wpdb; |
| 69 | 69 | /** |
| 70 | 70 | * Insert Topic |
| 71 | 71 | */ |
| @@ -169,8 +169,18 @@ | ||
| 169 | 169 | $video = tutor_utils()->sanitize_array($_POST['video']); |
| 170 | 170 | update_post_meta($post_ID, '_video', $video); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | + /** | |
| 174 | + * Adding author to instructor automatically | |
| 175 | + */ | |
| 176 | + | |
| 177 | + $author_id = $post->post_author; | |
| 178 | + $attached = (int) $wpdb->get_var(" SELECT COUNT(umeta_id) FROM {$wpdb->usermeta} WHERE user_id = {$author_id} AND meta_key = '_tutor_instructor_course_id' AND meta_value = {$post_ID} "); | |
| 179 | + if ( ! $attached){ | |
| 180 | + add_user_meta($author_id, '_tutor_instructor_course_id', $post_ID); | |
| 181 | + } | |
| 182 | + | |
| 173 | 183 | //Announcements |
| 174 | 184 | $announcement_title = tutor_utils()->avalue_dot('announcements.title', $_POST ); |
| 175 | 185 | if ( ! empty($announcement_title)){ |
| 176 | 186 | $title = sanitize_text_field(tutor_utils()->avalue_dot('announcements.title', $_POST )); |
| @@ -430,14 +440,14 @@ | ||
| 430 | 440 | |
| 431 | 441 | $instructors = array(); |
| 432 | 442 | |
| 433 | 443 | |
| 434 | - $not_in_sql = ''; | |
| 444 | + $not_in_sql = apply_filters('tutor_instructor_query_when_exists', " AND ID <1 "); | |
| 445 | + | |
| 435 | 446 | if ($saved_instructors){ |
| 436 | 447 | $saved_instructors_ids = wp_list_pluck($saved_instructors, 'ID'); |
| 437 | 448 | $instructor_not_in_ids = implode(',', $saved_instructors_ids); |
| 438 | - $activated = apply_filters('tutor_instructor_query_when_exists', " AND ID <1 "); | |
| 439 | - $not_in_sql = $activated."AND ID NOT IN($instructor_not_in_ids) "; | |
| 449 | + $not_in_sql .= "AND ID NOT IN($instructor_not_in_ids) "; | |
| 440 | 450 | } |
| 441 | 451 | |
| 442 | 452 | $search_sql = ''; |
| 443 | 453 | if ($search_terms){ |
| @@ -459,8 +469,13 @@ | ||
| 459 | 469 | $output .= '<p class="quiz-search-suggest-text">'.__('Search to get the specific instructors', 'tutor').'</p>'; |
| 460 | 470 | |
| 461 | 471 | }else{ |
| 462 | 472 | $output .= __('No instructor available or you have already added maximum instructors', 'tutor'); |
| 473 | + } | |
| 474 | + | |
| 475 | + | |
| 476 | + if ( ! defined('TUTOR_MT_VERSION')){ | |
| 477 | + $output .= '<p class="tutor-notice-warning" style="margin-top: 50px; font-size: 14px;">'. sprintf( __('To add unlimited multiple instructors in your course, get %sTutor LMS Pro%s', 'tutor'), '<a href="https://www.themeum.com/product/tutor-lms" target="_blank">', "</a>" ) .'</p>'; | |
| 463 | 478 | } |
| 464 | 479 | |
| 465 | 480 | wp_send_json_success(array('output' => $output)); |
| 466 | 481 | } |