LLMS_Processor_Membership_Bulk_Enroll::task( array $item )

Execute calculation for each item in the queue until all students in the course have been polled Stores the data in the postmeta table to be accessible via LLMS_Course


Parameters Parameters

$item

(array) (Required) array of processing data


Top ↑

Return Return

(boolean) true to keep the item in the queue and process again false to remove the item from the queue


Top ↑

Source Source

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

	public function task( $item ) {

		$this->log( sprintf( 'membership bulk enrollment task started for membership %1$d into course %2$d', $item['query_args']['post_id'], $item['course_id'] ) );
		$this->log( $item );

		// ensure the item has all the data we need to process it
		if ( ! is_array( $item ) || ! isset( $item['course_id'] ) || ! isset( $item['query_args'] ) || ! isset( $item['trigger'] ) ) {
			return false;
		}

		// turn the course data processor off
		$course_data_processor = LLMS()->processors()->get( 'course_data' );
		if ( $course_data_processor ) {
			$course_data_processor->disable();
		}

		$query = new LLMS_Student_Query( $item['query_args'] );

		if ( $query->found_results ) {
			foreach ( $query->get_students() as $student ) {
				$student->enroll( $item['course_id'], $item['trigger'] );
			}
		}

		if ( $query->is_last_page() ) {

			$this->log( sprintf( 'membership bulk enrollment completed for membership %1$d into course %2$d', $item['query_args']['post_id'], $item['course_id'] ) );

			// turn the course data processor back on
			if ( $course_data_processor ) {
				$course_data_processor->add_actions();
			}

			// process the course data
			do_action( 'llms_course_calculate_data', $item['course_id'] );

		}

		return false;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.15.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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