Skip to content

Course content stay in sync whenever a course's main instructor is changed - #2925

Open
sanjana4khan wants to merge 5 commits into
devfrom
instructor-change-issue
Open

Course content stay in sync whenever a course's main instructor is changed#2925
sanjana4khan wants to merge 5 commits into
devfrom
instructor-change-issue

Conversation

@sanjana4khan

@sanjana4khan sanjana4khan commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

When the Multi-Instructor addon is disabled, changing a course's author now reassigns all course content to the new instructor and resets the co-instructor list.
Linked PR(Pro)

@sanjana4khan sanjana4khan added the 4.0.0 Tutor v4.w0w label Jul 24, 2026
Comment thread classes/Course.php
*/
$author_id = $post->post_author;
if ( $requested_author_id && ( User::is_admin() || User::is_instructor() ) ) {
if ( User::is_admin( $requested_author_id ) || User::is_instructor( $requested_author_id, true ) ) {

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.

We can add this check if ( User::is_admin( $requested_author_id ) || User::is_instructor( $requested_author_id, true ) ) on the above line.

Comment thread classes/Course.php
CourseModel::update_course_content_author( $post_ID, (int) $author_id );
// Remove all existing instructors from the course and add the new one.
delete_metadata( 'user', 0, '_tutor_instructor_course_id', $post_ID, true );
add_user_meta( $author_id, '_tutor_instructor_course_id', $post_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.

add_user_meta( $author_id, '_tutor_instructor_course_id', $post_ID ); this code exists above. Please check.

Comment thread models/CourseModel.php
* Update the post_author of a course's content (topics, lessons,
* quizzes and assignments) to a given user.
*
* @since 4.0.3

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.

It should be 4.0.5

Comment thread classes/Course.php
if ( ! $attached && ! tutor_utils()->is_addon_enabled( 'tutor-multi-instructors' ) ) {
CourseModel::update_course_content_author( $post_ID, (int) $author_id );
// Remove all existing instructors from the course and add the new one.
delete_metadata( 'user', 0, '_tutor_instructor_course_id', $post_ID, true );

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.

Before deleting, how are we showing a warning alert?

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.

2 participants