LLMS_Membership::add_auto_enroll_courses( array|int $course_ids, bool $replace = false )
Add courses to autoenrollment by id
Parameters Parameters
- $course_ids
-
(array|int) (Required) Array of course id or course id as int.
- $replace
-
(bool) (Optional) When
true, replaces all existing courses with$course_ids, when false merges$course_idswith existing courses. Defaultfalse.Default value: false
Return Return
(boolean) Returns true on success, and false on error or if the value in the db is unchanged.
Source Source
File: includes/models/model.llms.membership.php
public function add_auto_enroll_courses( $course_ids, $replace = false ) {
// allow a single course_id to be passed in.
if ( ! is_array( $course_ids ) ) {
$course_ids = array( $course_ids );
}
// add existing courses to the array if replace is false.
if ( ! $replace ) {
$course_ids = array_merge( $course_ids, $this->get_auto_enroll_courses() );
}
return $this->set( 'auto_enroll', array_unique( $course_ids ) );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.30.0 | Added optional $replace argument. |
| 3.0.0 | Introduced. |