From d9a85d4a41526de94d0d8dbbe8ce7c3cb54cbc35 Mon Sep 17 00:00:00 2001 From: "Md.Harun-Ur-Rashid" Date: Thu, 3 Dec 2026 15:10:56 +0600 Subject: [PATCH 1/7] fix: add course accessibility check in reviews and fix course property access in quiz --- classes/Quiz.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Quiz.php b/classes/Quiz.php index a66973e45b..76e3f94442 100644 --- a/classes/Quiz.php +++ b/classes/Quiz.php @@ -722,7 +722,7 @@ public function start_the_quiz() { } // Check & die if don't have quiz access. - QuizModel::has_quiz_access( $quiz_id, $course->id ); + QuizModel::has_quiz_access( $quiz_id, $course->ID ); if ( ! self::has_supported_questions( $quiz_id ) ) { wp_die( esc_html( self::unavailable_quiz_message() ) ); From 15fd596c1de138e1ab206c8de4d60d05e9e27268 Mon Sep 17 00:00:00 2001 From: "Md.Harun-Ur-Rashid" Date: Thu, 3 Dec 2026 15:11:36 +0600 Subject: [PATCH 2/7] fix: unauthorized review data access --- classes/Reviews.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/classes/Reviews.php b/classes/Reviews.php index e94c0957b8..d8b1272dcc 100644 --- a/classes/Reviews.php +++ b/classes/Reviews.php @@ -15,6 +15,8 @@ use Tutor\Core\Input; use Tutor\Helpers\QueryHelper; use Tutor\Helpers\UrlHelper; +use Tutor\Models\CourseModel; + /** * Handle ratings related logics * @@ -99,6 +101,11 @@ public static function delete( int $id ): bool { public function tutor_single_course_reviews_load_more() { tutor_utils()->checking_nonce(); + $course_id = Input::post( 'course_id', 0, Input::TYPE_INT ); + if ( ! CourseModel::is_course_accessible( $course_id ) ) { + wp_send_json_error( array( 'message' => tutor_utils()->error_message( 'invalid_req' ) ) ); + } + ob_start(); tutor_load_template( 'single.course.reviews' ); $html = ob_get_clean(); From 7568b6513796333c54287989e0b55ac8e6f7c112 Mon Sep 17 00:00:00 2001 From: "Md.Harun-Ur-Rashid" Date: Thu, 3 Dec 2026 15:13:54 +0600 Subject: [PATCH 3/7] fix: hook fired even data update failed --- classes/Reviews.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/Reviews.php b/classes/Reviews.php index d8b1272dcc..2eb7af9f6a 100644 --- a/classes/Reviews.php +++ b/classes/Reviews.php @@ -133,7 +133,10 @@ public function tutor_change_review_status() { $status = Input::post( 'status' ); global $wpdb; - $wpdb->update( $wpdb->comments, array( 'comment_approved' => $status ), array( 'comment_ID' => $review_id ) ); + $updated = $wpdb->update( $wpdb->comments, array( 'comment_approved' => $status ), array( 'comment_ID' => $review_id ) ); + if ( ! $updated ) { + wp_send_json_error( array( 'message' => __( 'Failed to update review status', 'tutor' ) ) ); + } if ( 'approved' === $status ) { do_action( 'tutor_course_review_approved', $review_id ); From 6041789566cb98aec8617d159b42871e92a5d687 Mon Sep 17 00:00:00 2001 From: "Md.Harun-Ur-Rashid" Date: Thu, 3 Dec 2026 15:18:30 +0600 Subject: [PATCH 4/7] fix: review delete does not check comment type --- classes/Reviews.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/classes/Reviews.php b/classes/Reviews.php index 2eb7af9f6a..23eb53ccb2 100644 --- a/classes/Reviews.php +++ b/classes/Reviews.php @@ -54,19 +54,22 @@ public function __construct() { public function delete_review() { tutor_utils()->checking_nonce(); - // Check if user is privileged. - if ( ! current_user_can( 'administrator' ) ) { + if ( ! User::is_admin() ) { wp_send_json_error( array( 'message' => tutor_utils()->error_message() ) ); } + $review_id = Input::post( 'id', 0, Input::TYPE_INT ); - $delete = self::delete( $review_id ); + $comment = get_comment( $review_id ); + if ( $comment->comment_type !== self::COURSE_RATING ) { + wp_send_json_error( array( 'message' => __( 'Invalid review ID.', 'tutor' ) ) ); + } - if ( $delete ) { - wp_send_json_success(); - } else { - wp_send_json_error( array( 'message' => __( 'Something went wrong!', 'tutor' ) ) ); + $delete = self::delete( $review_id ); + if ( ! $delete ) { + wp_send_json_error( array( 'message' => __( 'Failed to delete review.', 'tutor' ) ) ); } - exit; + + wp_send_json_success( array( 'message' => __( 'Review deleted successfully.', 'tutor' ) ) ); } /** From 976e52a83b3fba44977a8eb9680515f40c26105a Mon Sep 17 00:00:00 2001 From: "Md.Harun-Ur-Rashid" Date: Thu, 3 Dec 2026 15:45:10 +0600 Subject: [PATCH 5/7] fix: negative value accepted --- classes/Shortcode.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/classes/Shortcode.php b/classes/Shortcode.php index 17bc52a75f..aa1733a3a1 100644 --- a/classes/Shortcode.php +++ b/classes/Shortcode.php @@ -300,7 +300,7 @@ function ( $id ) { private function prepare_instructor_list( $current_page, $atts, $cat_ids = array(), $keyword = '' ) { $default_pagination = tutor_utils()->get_option( 'pagination_per_page', 9 ); - $limit = (int) sanitize_text_field( tutor_utils()->array_get( 'count', $atts, $default_pagination ) ); + $limit = absint( sanitize_text_field( tutor_utils()->array_get( 'count', $atts, $default_pagination ) ) ); $page = $current_page - 1; $rating_filter = Input::post( 'rating_filter', '' ); @@ -459,18 +459,13 @@ public function show_more() { public function load_filtered_instructor() { tutor_utils()->checking_nonce(); - // phpcs:disable WordPress.Security.NonceVerification.Missing --nonce already verified + // phpcs:ignore WordPress.Security.NonceVerification.Missing --nonce already verified $_post = tutor_sanitize_data( $_POST ); - $current_page = (int) sanitize_text_field( tutor_utils()->array_get( 'current_page', $_post, 1 ) ); - $keyword = (string) sanitize_text_field( tutor_utils()->array_get( 'keyword', $_post, '' ) ); + $current_page = max( 1, Input::post( 'current_page', 1, Input::TYPE_INT ) ); + $keyword = Input::post( 'keyword', '' ); $category = (array) tutor_utils()->array_get( 'category', $_post, array() ); - $category = array_filter( - $category, - function ( $cat ) { - return is_numeric( $cat ); - } - ); + $category = array_filter( $category, fn( $cat ) => is_numeric( $cat ) ); $data = $this->prepare_instructor_list( $current_page, $_post, $category, $keyword ); From bee9620abb5744b0f5bd2951514e7c0d6f80de7e Mon Sep 17 00:00:00 2001 From: "Md.Harun-Ur-Rashid" Date: Thu, 3 Dec 2026 15:53:04 +0600 Subject: [PATCH 6/7] fix: negative value accepted --- classes/Shortcode.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/classes/Shortcode.php b/classes/Shortcode.php index aa1733a3a1..1dcff5689b 100644 --- a/classes/Shortcode.php +++ b/classes/Shortcode.php @@ -301,8 +301,13 @@ private function prepare_instructor_list( $current_page, $atts, $cat_ids = array $default_pagination = tutor_utils()->get_option( 'pagination_per_page', 9 ); $limit = absint( sanitize_text_field( tutor_utils()->array_get( 'count', $atts, $default_pagination ) ) ); - $page = $current_page - 1; - $rating_filter = Input::post( 'rating_filter', '' ); + $limit = max( 1, $limit ); + + $current_page = max( 1, absint( $current_page ) ); + $page = $current_page - 1; + + $rating_filter = Input::post( 'rating_filter', '' ); + $start = $limit * $page; /** * Sort by Relevant | New | Popular @@ -311,8 +316,8 @@ private function prepare_instructor_list( $current_page, $atts, $cat_ids = array */ $short_by = Input::post( 'short_by', 'ASC' ); - $instructors = tutor_utils()->get_instructors( $limit * $page, $limit, $keyword, '', '', $short_by, 'approved', $cat_ids, $rating_filter ); - $instructors_count = tutor_utils()->get_instructors( $limit * $page, $limit, $keyword, '', '', $short_by, 'approved', $cat_ids, $rating_filter, true ); + $instructors = tutor_utils()->get_instructors( $start, $limit, $keyword, '', '', $short_by, 'approved', $cat_ids, $rating_filter ); + $instructors_count = tutor_utils()->get_instructors( $start, $limit, $keyword, '', '', $short_by, 'approved', $cat_ids, $rating_filter, true ); $layout = sanitize_text_field( tutor_utils()->array_get( 'layout', $atts, '' ) ); $layout = in_array( $layout, $this->instructor_layout ) ? $layout : tutor_utils()->get_option( 'instructor_list_layout', $this->instructor_layout[0] ); From 615bfe772513c4d7b873c61bc39e46cd550966d5 Mon Sep 17 00:00:00 2001 From: "Md.Harun-Ur-Rashid" Date: Thu, 3 Dec 2026 16:03:00 +0600 Subject: [PATCH 7/7] fix: instructor can be searched by email --- classes/Shortcode.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/classes/Shortcode.php b/classes/Shortcode.php index 1dcff5689b..d5d7b91ff2 100644 --- a/classes/Shortcode.php +++ b/classes/Shortcode.php @@ -469,6 +469,11 @@ public function load_filtered_instructor() { $current_page = max( 1, Input::post( 'current_page', 1, Input::TYPE_INT ) ); $keyword = Input::post( 'keyword', '' ); + // Prevent search by email address from public instructor list. + if ( strpos( $keyword, '@' ) !== false ) { + $keyword = ''; + } + $category = (array) tutor_utils()->array_get( 'category', $_post, array() ); $category = array_filter( $category, fn( $cat ) => is_numeric( $cat ) );