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_ids with existing courses. Default false.

Default value: false


Top ↑

Return Return

(boolean) Returns true on success, and false on error or if the value in the db is unchanged.


Top ↑

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 ) );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.30.0 Added optional $replace argument.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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