LLMS_Generator_Courses::generate_courses( array $raw )

Generator called for bulk course imports

Description Description

Parameters Parameters


(array) (Required) Raw data array.

Top ↑

Return Return


Top ↑

Source Source

File: includes/class-llms-generator-courses.php

	public function generate_courses( $raw ) {

		if ( empty( $raw['courses'] ) ) {
			throw new Exception( __( 'Raw data is missing the required "courses" array.', 'lifterlms' ), self::ERROR_GEN_MISSING_REQUIRED );
		} elseif ( ! is_array( $raw['courses'] ) ) {
			throw new Exception( __( 'The raw "courses" item must be an array.', 'lifterlms' ), self::ERROR_GEN_INVALID_FORMAT );

		$courses = array();

		foreach ( $raw['courses'] as $raw_course ) {
			unset( $raw_course['_generator'], $raw_course['_version'] );
			$courses[] = $this->create_course( $raw_course );


		return $courses;


Top ↑

Changelog Changelog

Version Description
4.7.0 Moved from LLMS_Generator to LLMS_Abstract_Generator_Courses. Updated method access from private to public. Throws an exception in favor of returning null when an error is encountered. Returns an array of generated course IDs on success.
3.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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