LLMS_Post_Instructors::pre_set_instructors( array $instructors = array() )

Format an instructors array for saving to the db.


Parameters Parameters

$instructors

(array) (Optional) Array of full (or partial) instructor data.

Default value: array()


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/models/model.llms.post.instructors.php

	public function pre_set_instructors( $instructors = array() ) {

		/**
		 * We cannot allow no instructors to exist
		 * so we'll revert to the default `post_author`.
		 */
		if ( ! $instructors ) {
			// Clear so the getter will retrieve the default author.
			$this->post->set( 'instructors', array() );
			$instructors = $this->get_instructors();
		}

		// Allow partial arrays to be passed & we'll fill em up with defaults.
		foreach ( $instructors as $i => &$instructor ) {

			$instructor       = wp_parse_args( $instructor, llms_get_instructors_defaults() );
			$instructor['id'] = absint( $instructor['id'] );

			// Remove instructors without an ID.
			if ( empty( $instructor['id'] ) ) {
				unset( $instructors[ $i ] );
			}
		}

		return array_values( $instructors );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.25.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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