Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

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

Create a new access plan


Description Description


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 value: null


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/class.llms.generator.php

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

		$author_id = $this->get_author_id_from_raw( $raw, $fallback_author_id );
		if ( isset( $raw['author'] ) ) {
			unset( $raw['author'] );
		}

		// insert the plan
		$plan = new LLMS_Access_Plan( 'new', array(
			'post_author' => $author_id,
			'post_content' => isset( $raw['content'] ) ? $raw['content'] : null,
			'post_date' => isset( $raw['date'] ) ? $this->format_date( $raw['date'] ) : null,
			'post_modified' => isset( $raw['modified'] ) ? $this->format_date( $raw['modified'] ) : null,
			'post_status' => isset( $raw['status'] ) ? $raw['status'] : $this->get_default_post_status(),
			'post_title' => $raw['title'],
		) );

		$this->increment( 'plans' );

		unset( $raw['content'], $raw['date'], $raw['modified'], $raw['name'], $raw['status'], $raw['title'] );

		unset( $raw['product_id'] );
		$plan->set( 'product_id', $course_id );

		// store the from the import if there is one
		if ( isset( $raw['id'] ) ) {
			$plan->set( 'generated_from_id', $raw['id'] );
			unset( $raw['id'] );
		}

		foreach ( $raw as $key => $val ) {
			$plan->set( $key, $val );
		}

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

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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