PluginProbe
Tutor LMS – eLearning and online course solution / 3.9.2
Tutor LMS – eLearning and online course solution v3.9.2
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
← All changes | classes/Student.php +14 -85 trunk3.9.2 View file →
@@ -9,10 +9,8 @@
9 9 */
10 10
11 11 namespace TUTOR;
12 12
13 -use Tutor\GDPR\Controllers\LegalConsent;
14 -
15 13 if ( ! defined( 'ABSPATH' ) ) {
16 14 exit;
17 15 }
18 16
@@ -59,8 +57,9 @@
59 57 }
60 58
61 59 // Checking nonce.
62 60 tutor_utils()->checking_nonce();
61 +
63 62 $required_fields = apply_filters(
64 63 'tutor_student_registration_required_fields',
65 64 array(
66 65 'first_name' => __( 'First name field is required', 'tutor' ),
@@ -77,8 +76,9 @@
77 76 // Registration error push into validation_errors.
78 77 $errors = apply_filters( 'registration_errors', new \WP_Error(), '', '' );
79 78 foreach ( $errors->errors as $key => $value ) {
80 79 $validation_errors[ $key ] = $value[0];
80 +
81 81 }
82 82
83 83 foreach ( $required_fields as $required_key => $required_value ) {
84 84 if ( empty( Input::post( $required_key, '' ) ) ) {
@@ -85,18 +85,11 @@
85 85 $validation_errors[ $required_key ] = $required_value;
86 86 }
87 87 }
88 88
89 - // @since 4.0.0 legal consent added.
90 - $validate_consent = LegalConsent::validate_consent( LegalConsent::DISPLAY_ON_STD_REG, $_POST );
91 - if ( is_wp_error( $validate_consent ) ) {
92 - $validation_errors[ $validate_consent->get_error_code() ] = $validate_consent->get_error_message();
93 - }
94 -
95 89 if ( ! filter_var( tutor_utils()->input_old( 'email' ), FILTER_VALIDATE_EMAIL ) ) {
96 90 $validation_errors['email'] = __( 'Valid E-Mail is required', 'tutor' );
97 91 }
98 -
99 92 if ( tutor_utils()->input_old( 'password' ) !== tutor_utils()->input_old( 'password_confirmation' ) ) {
100 93 $validation_errors['password_confirmation'] = __( 'Your passwords should match each other. Please recheck.', 'tutor' );
101 94 }
102 95
@@ -110,9 +103,10 @@
110 103 $last_name = sanitize_text_field( tutor_utils()->input_old( 'last_name' ) );
111 104 $email = sanitize_text_field( tutor_utils()->input_old( 'email' ) );
112 105 $user_login = sanitize_text_field( tutor_utils()->input_old( 'user_login' ) );
113 106 $password = sanitize_text_field( tutor_utils()->input_old( 'password' ) );
114 - $userdata = array(
107 +
108 + $userdata = array(
115 109 'user_login' => $user_login,
116 110 'user_email' => $email,
117 111 'first_name' => $first_name,
118 112 'last_name' => $last_name,
@@ -120,10 +114,12 @@
120 114 );
121 115
122 116 global $wpdb;
123 117 $wpdb->query( 'START TRANSACTION' );
118 +
124 119 $user_id = wp_insert_user( $userdata );
125 120 $enroll_attempt = Input::post( 'tutor_course_enroll_attempt', '' );
121 +
126 122 if ( is_wp_error( $user_id ) ) {
127 123 $this->error_msgs = $user_id->get_error_messages();
128 124 add_filter( 'tutor_student_register_validation_errors', array( $this, 'tutor_student_form_validation_errors' ) );
129 125 return;
@@ -130,14 +126,10 @@
130 126 }
131 127
132 128 $user = get_user_by( 'id', $user_id );
133 129
134 - $redirect_url = '';
135 -
136 130 $is_req_email_verification = apply_filters( 'tutor_require_email_verification', false );
137 131 if ( $is_req_email_verification ) {
138 - $redirect_url = tutor_utils()->student_register_url();
139 -
140 132 do_action( 'tutor_send_verification_mail', $user, $enroll_attempt );
141 133 $reg_done = apply_filters( 'tutor_registration_done', true );
142 134 if ( ! $reg_done ) {
143 135 $wpdb->query( 'ROLLBACK' );
@@ -143,9 +135,8 @@
143 135 $wpdb->query( 'ROLLBACK' );
144 136 return;
145 137 } else {
146 138 $wpdb->query( 'COMMIT' );
147 -
148 139 }
149 140 } else {
150 141 /**
151 142 * Tutor Free - reqular student reg process.
@@ -153,10 +144,10 @@
153 144 $wpdb->query( 'COMMIT' );
154 145
155 146 wp_set_current_user( $user_id, $user->user_login );
156 147 wp_set_auth_cookie( $user_id );
148 +
157 149 do_action( 'tutor_after_student_signup', $user_id );
158 -
159 150 // since 1.9.8 do enroll if guest attempt to enroll.
160 151 if ( ! empty( $enroll_attempt ) ) {
161 152 do_action( 'tutor_do_enroll_after_login_if_attempt', $enroll_attempt, $user_id );
162 153 }
@@ -161,16 +152,18 @@
161 152 do_action( 'tutor_do_enroll_after_login_if_attempt', $enroll_attempt, $user_id );
162 153 }
163 154
164 155 // Redirect page.
165 - $redirect_url = tutor_utils()->array_get( 'redirect_to', $_REQUEST ); //phpcs:ignore
166 - if ( ! $redirect_url ) {
167 - $redirect_url = tutor_utils()->tutor_dashboard_url();
156 + $redirect_page = tutor_utils()->array_get( 'redirect_to', $_REQUEST ); //phpcs:ignore
157 + if ( ! $redirect_page ) {
158 + $redirect_page = tutor_utils()->tutor_dashboard_url();
168 159 }
160 + wp_safe_redirect( apply_filters( 'tutor_student_register_redirect_url', $redirect_page, $user ) );
161 + die();
169 162 }
170 163
171 - do_action( 'tutor_new_user_registered', $user, $validate_consent );
172 - wp_safe_redirect( apply_filters( 'tutor_student_register_redirect_url', tutor_utils()->get_nocache_url( $redirect_url ), $user ) );
164 + $registration_page = tutor_utils()->student_register_url();
165 + wp_safe_redirect( $registration_page );
173 166 die();
174 167 }
175 168
176 169 /**
@@ -339,70 +332,6 @@
339 332 }
340 333
341 334 wp_send_json_success( array( 'message' => __( 'Social Profile Updated', 'tutor' ) ) );
342 335 die();
343 - }
344 -
345 - /**
346 - * Get courses tab configuration for student dashboard
347 - *
348 - * Generates the tab structure for displaying student courses with dropdown options
349 - * for enrolled, active, and completed courses including counts and navigation URLs.
350 - *
351 - * @since 4.0.0
352 - *
353 - * @param string $active_tab The currently active tab identifier.
354 - * @param array $post_type_args Query arguments for post type filtering.
355 - * @param int $enrolled_course_count Number of enrolled courses.
356 - * @param int $active_course_count Number of active courses.
357 - * @param int $completed_course_count Number of completed courses.
358 - *
359 - * @return array Array containing tab configuration with dropdown options
360 - */
361 - public function get_courses_tab( $active_tab, $post_type_args, $enrolled_course_count, $active_course_count, $completed_course_count ) {
362 - $courses_tab = array(
363 - array(
364 - 'type' => 'dropdown',
365 - 'active' => ( ( 'courses' === $active_tab ) || ( 'courses/active-courses' === $active_tab ) || ( 'courses/completed-courses' === $active_tab ) ) ? true : false,
366 - 'options' => array(
367 - array(
368 - 'label' => __( 'Enrolled', 'tutor' ),
369 - 'icon' => Icon::ENROLLED,
370 - 'url' => esc_url( add_query_arg( $post_type_args, tutor_utils()->get_tutor_dashboard_page_permalink( 'courses' ) ) ),
371 - 'active' => 'courses' === $active_tab ? true : false,
372 - 'count' => $enrolled_course_count,
373 - ),
374 - array(
375 - 'label' => __( 'Active', 'tutor' ),
376 - 'icon' => Icon::PLAY_LINE_2,
377 - 'url' => esc_url( add_query_arg( $post_type_args, tutor_utils()->get_tutor_dashboard_page_permalink( 'courses/active-courses' ) ) ),
378 - 'active' => 'courses/active-courses' === $active_tab ? true : false,
379 - 'count' => $active_course_count,
380 - ),
381 - array(
382 - 'label' => __( 'Complete', 'tutor' ),
383 - 'icon' => Icon::COMPLETED_CIRCLE,
384 - 'url' => esc_url( add_query_arg( $post_type_args, tutor_utils()->get_tutor_dashboard_page_permalink( 'courses/completed-courses' ) ) ),
385 - 'active' => 'courses/completed-courses' === $active_tab ? true : false,
386 - 'count' => $completed_course_count,
387 - ),
388 - ),
389 - ),
390 - array(
391 - 'type' => 'link',
392 - 'label' => __( 'Wishlist', 'tutor' ),
393 - 'icon' => Icon::WISHLIST,
394 - 'url' => esc_url( tutor_utils()->tutor_dashboard_url( 'courses/wishlist' ) ),
395 - 'active' => 'courses/wishlist' === $active_tab ? true : false,
396 - ),
397 - array(
398 - 'type' => 'link',
399 - 'label' => __( 'Quiz Attempts', 'tutor' ),
400 - 'icon' => Icon::QUIZ_2,
401 - 'url' => esc_url( tutor_utils()->tutor_dashboard_url( 'courses/my-quiz-attempts' ) ),
402 - 'active' => 'courses/my-quiz-attempts' === $active_tab ? true : false,
403 - ),
404 - );
405 -
406 - return $courses_tab;
407 336 }
408 337 }