Warning: This method has been deprecated. There is not a replacement instead.

LLMS_Lesson_Handler::assign_to_course( int $course_id, int $section_id, int $lesson_id, bool $duplicate = true, bool $reset_order = true )

Assigns the lesson to a section and course, optionally by duplicating it.


Parameters Parameters

$course_id

(int) (Required)

$section_id

(int) (Required)

$lesson_id

(int) (Required)

$duplicate

(bool) (Optional)

Default value: true

$reset_order

(bool) (Optional)

Default value: true


Top ↑

Return Return

(false|int|WP_Error)


Top ↑

Source Source

File: includes/class.llms.lesson.handler.php

	public static function assign_to_course( $course_id, $section_id, $lesson_id, $duplicate = true, $reset_order = true ) {

		llms_deprecated_function( __METHOD__, '5.7.0' );

		// Get position of next lesson.
		$section      = new LLMS_Section( $section_id );
		$lesson_order = $section->get_next_available_lesson_order();

		// First determine if lesson is associated with a course.
		// We need to know this because if it is already associated then we duplicate it and assign the dupe.
		$parent_course  = get_post_meta( $lesson_id, '_llms_parent_course', true );
		$parent_section = get_post_meta( $lesson_id, '_llms_parent_section', true );

		// Parent course exists, lets dupe this baby!.
		if ( $parent_course && true == $duplicate ) {
			$lesson_id = self::duplicate_lesson( $course_id, $section_id, $lesson_id );
		} else {
			// Add parent section and course to new lesson.
			update_post_meta( $lesson_id, '_llms_parent_section', $section_id );
			update_post_meta( $lesson_id, '_llms_parent_course', $course_id );

		}

		if ( $reset_order ) {
			update_post_meta( $lesson_id, '_llms_order', $lesson_order );
		}

		return $lesson_id;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.7.0 There is not a replacement.
1.2.4 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.