Skip to content

Added backend validation for student activities in course#2676

Open
Anindra123 wants to merge 6 commits into4.0.0-devfrom
validation_fixes
Open

Added backend validation for student activities in course#2676
Anindra123 wants to merge 6 commits into4.0.0-devfrom
validation_fixes

Conversation

@Anindra123
Copy link
Copy Markdown
Collaborator

No description provided.

@Anindra123 Anindra123 added the 4.0.0 Tutor v4.w0w label May 7, 2026
Comment thread classes/Course.php Outdated
$can_enroll = $this->validate_course_enrollment_period( $course_id );
if ( ! $can_enroll ) {
$referer_url = wp_get_referer();
wp_safe_redirect( tutor_utils()->get_nocache_url( $referer_url ) );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the wp_get_referer() returns false?

Comment thread classes/Course.php Outdated
*
* @return bool
*/
public function validate_course_enrollment_period( $course_id ) {
Copy link
Copy Markdown
Collaborator

@shewa12 shewa12 May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the typehint (int) & validate the $course_id

Comment thread classes/Course.php Outdated
*
* @return bool
*/
public function validate_course_enrollment_period( $course_id ) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name should be changed. We are restricting enrollment based on the period clause. The method name should reflect the implementation.

Comment thread assets/src/js/front/course/_wishlist.js Outdated
}
} else {
tutor_toast(__('Error', 'tutor-pro'), data?.data?.message ?? 'Something went wrong!!', 'error');
if ( data.data.message ) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this like if ( data?.data?.message ) {

Comment thread assets/src/js/front/pages/course-landing.js
Comment thread assets/src/js/frontend/learning-area/common.ts Outdated
Comment thread assets/src/js/frontend/learning-area/sidebar.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0.0 Tutor v4.w0w

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants