LLMS_Generator_Courses::create_access_plan( array $raw, int $course_id, int $fallback_author_id = null )

Create a new access plan


Parameters Parameters

$raw

(array) (Required) Raw Access Plan Data.

$course_id

(int) (Required) WP Post ID of a LLMS Course to assign the access plan to.

$fallback_author_id

(int) (Optional) WP User ID to use for the access plan author if no author is supplied in the raw data. Default is null.<br> When not supplied the fall back will be on the current user ID.

Default value: null


Top ↑

Return Return

(int)


Top ↑

Source Source

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

	protected function create_access_plan( $raw, $course_id, $fallback_author_id = null ) {

		/**
		 * Filter raw course import data prior to generation
		 *
		 * @since 4.7.0
		 *
		 * @param array          $raw       Raw course data array.
		 * @param LLMS_Generator $generator Generator instance.
		 */
		$raw = apply_filters( 'llms_generator_before_new_access_plan', $raw, $this );

		// Force course relationship.
		$raw['product_id'] = $course_id;

		$plan = $this->create_post( 'access_plan', $raw, $fallback_author_id );
		if ( ! $plan ) {
			return null;
		}

		/**
		 * Action triggered immediately following generation of a new acess plan
		 *
		 * @since 4.7.0
		 *
		 * @param LLMS_Access_Plan $plan      Generated access plan object.
		 * @param array            $raw       Original raw course data array.
		 * @param LLMS_Generator   $generator Generator instance.
		 */
		do_action( 'llms_generator_new_access_plan', $plan, $raw, $this );

		return $plan->get( 'id' );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Sideload images attached to the post, use create_post() from abstract, add hooks.
4.3.3 Use an empty string in favor of null for an empty post_content field.
3.7.3 Unknown.
3.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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