Skip to content

Conversation

@shewa12
Copy link
Collaborator

@shewa12 shewa12 commented Jan 14, 2026

  1. A new button is added on the user profile drop-down menu switch profile to learner/instructor
  2. JS & PHP Script added to handle the Ajax request
  3. A common type AjaxResponse added
  4. Hid the become an instructor button for the admin user

@shewa12 shewa12 added the 4.0.0 Tutor v4.w0w label Jan 14, 2026
{
onSuccess: (res: AjaxResponse) => {
window.TutorCore.toast.success(res?.message);
setTimeout(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this delay? In production ajax calls usually takes longer times.

}

$switch_mode = '';
$current_mode = Input::post( 'current_mode' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

The variable name is confusing because the user already has a current mode.
Use switch_mode to clearly indicate the target mode.

Copy link
Collaborator

Choose a reason for hiding this comment

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

$switch_mode   = Input('switch_mode' );
$profile_mode  = self::VIEW_AS_STUDENT === $switch_mode ? self::VIEW_AS_STUDENT : self::VIEW_AS_INSTRUCTOR;
update_user_meta( $user_id, self::VIEW_MODE_USER_META, $profile_mode );

$is_instructor = self::is_instructor( $user_id, true );
$is_admin = self::is_admin( $user_id );

$default_mode = $is_instructor || $is_admin ? self::VIEW_AS_INSTRUCTOR : self::VIEW_AS_STUDENT;
Copy link
Collaborator

Choose a reason for hiding this comment

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

To check multiple condition for ternary use ( )

$default_mode = ( $is_instructor || $is_admin ) ? self::VIEW_AS_INSTRUCTOR : self::VIEW_AS_STUDENT;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of defining a new interface, use TutorMutationResponse

shewa12 and others added 4 commits January 16, 2026 16:17
To me, it seems sensible to keep things together for a single mutation.

Co-authored-by: Fahim Faisal <42368238+b-l-i-n-d@users.noreply.github.com>
@shewa12 shewa12 merged commit 1ae9dfa into 4.0.0-dev Jan 16, 2026
0 of 8 checks passed
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.

5 participants