LLMS_Processor_Membership_Bulk_Enroll::dispatch_enrollment( int $membership_id, int $course_id )

Action triggered to queue all students who need to be enrolled


Parameters Parameters

$membership_id

(int) (Required) WP Post ID of the membership.

$course_id

(int) (Required) WP Post ID of the course to enroll members into.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/processors/class.llms.processor.membership.bulk.enroll.php

	public function dispatch_enrollment( $membership_id, $course_id ) {

		$this->log( sprintf( 'membership bulk enrollment dispatched for membership %1$d into course %2$d', $membership_id, $course_id ) );

		// cancel process in case it's currently running
		$this->cancel_process();

		$args = array(
			'post_id'  => $membership_id,
			'statuses' => 'enrolled',
			'page'     => 1,
			'per_page' => 250,
		);

		$query = new LLMS_Student_Query( $args );

		if ( $query->has_results() ) {

			while ( $args['page'] <= $query->get_max_pages() ) {

				$this->push_to_queue(
					array(
						'course_id'  => $course_id,
						'query_args' => $args,
						'trigger'    => sprintf( 'membership_%d', $membership_id ),
					)
				);

				$args['page']++;

			}

			$this->save()->dispatch();

			$this->log( sprintf( 'membership bulk enrollment started for membership %1$d into course %2$d', $membership_id, $course_id ) );

		}

	}

Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Don't access LLMS_Student_Query properties directly.
3.15.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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