Warning: This method has been deprecated.

LLMS_Post_Handler::create_lesson( int $course_id, int $section_id, string $title = '', string $excerpt = '' )

Create lesson


Parameters Parameters

$course_id

(int) (Required) WP_Post ID of the course.

$section_id

(int) (Required) WP_Post ID of the lesson's parent section.

$title

(string) (Optional) lesson title.

Default value: ''

$excerpt

(string) (Optional) Option excerpt.

Default value: ''


Top ↑

Return Return

(int) WP_Post ID of the created lesson.


Top ↑

Source Source

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

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
public static function create_lesson( $course_id, $section_id, $title = '', $excerpt = '' ) {
 
    // No course id or section id? no new lesson!.
    if ( ! isset( $course_id ) || ! isset( $course_id ) ) {
        return;
    }
 
    // Set the lesson_order variable.
    // Get the count of lessons in the section.
    $section      = new LLMS_Section( $section_id );
    $lesson_order = $section->get_next_available_lesson_order();
 
    $title = isset( $title ) ? $title : 'New Lesson';
 
    $post_id = self::create( 'lesson', $title, $excerpt );
 
    // If post created set parent section, parent course and order determined above.
    if ( $post_id ) {
        update_post_meta( $post_id, '_llms_order', $lesson_order );
 
        $lesson                 = new LLMS_Lesson( $post_id );
        $updated_parent_section = $lesson->set_parent_section( $section_id );
        $updated_parent_course  = $lesson->set_parent_course( $course_id );
 
    }
 
    return $post_id;
}


Top ↑

Changelog Changelog

Changelog
Version Description
4.4.3 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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