LLMS_Membership::get_auto_enroll_courses()

Get an array of the auto enrollment course ids


Description Description

Uses a custom function due to the default "get_array" returning an array with an empty string


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/models/model.llms.membership.php

177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
public function get_auto_enroll_courses() {
 
    // Ensure an array when metadata is not set.
    $courses = isset( $this->auto_enroll ) ? $this->get( 'auto_enroll' ) : array();
 
    // Exclude unpublished courses.
    $courses = array_values(
        array_filter(
            $courses,
            function( $id ) {
                return 'publish' === get_post_status( $id );
            }
        )
    );
 
    /**
     * Filters the list of the membership's auto enroll courses
     *
     * @since 3.0.0
     *
     * @param int[]           $courses    List of LLMS_Course IDs.
     * @param LLMS_Membership $membership Membership post object.
     */
    return apply_filters( 'llms_membership_get_auto_enroll_courses', $courses, $this );
}


Top ↑

Changelog Changelog

Changelog
Version Description
4.15.0 Exclude unpublished courses from the return array.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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