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

Format an instructors array for saving to the db.


Description Description


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 current 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.





Permalink: