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.


Description Description

Stores the data in the postmeta table to be accessible via LLMS_Course.


Top ↑

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->has_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
6.0.0 Replaced access of LLMS_Student_Query::$found_results protected property with LLMS_Student_Query::has_results().
3.15.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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