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

LLMS_Post_Handler::create_section( int $course_id, string $title = '' )

Creates a new Section


Parameters Parameters

$course_id

(int) (Required) The parent course id.

$title

(string) (Optional) An optional title for the section.

Default value: ''


Top ↑

Return Return

(int) Post id of the section.


Top ↑

Source Source

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

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
public static function create_section( $course_id, $title = '' ) {
 
    llms_deprecated_function( __METHOD__, '5.7.0' );
 
    // No course id? no new section!.
    if ( ! isset( $course_id ) ) {
        return;
    }
 
    // Set the section_order variable.
    // Get the count of sections in the course and add 1.
    $course        = new LLMS_Course( $course_id );
    $sections      = $course->get_sections( 'posts' );
    $section_order = count( $sections ) + 1;
 
    $title = isset( $title ) ? $title : 'New Section';
 
    $post_id = self::create( 'section', $title );
 
    // If post created set parent course and order to order determined above.
    if ( $post_id ) {
        update_post_meta( $post_id, '_llms_order', $section_order );
 
        $section               = new LLMS_Section( $post_id );
        $updated_parent_course = $section->set_parent_course( $course_id );
    }
 
    return $post_id;
}


Top ↑

Changelog Changelog

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

Top ↑

User Contributed Notes User Contributed Notes

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