LLMS_Student::is_favorite( int $object_id, string $object_type = 'lesson' )

Determine if the student has favorited a lesson.


Parameters Parameters

$object_id

(int) (Required) WP Post ID of the object to mark/unmark as favorite.

$object_type

(string) (Optional) The object type, currently only 'lesson'.

Default value: 'lesson'


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/models/model.llms.student.php

	public function is_favorite( $object_id, $object_type = 'lesson' ) {

		$query = new LLMS_Query_User_Postmeta(
			array(
				'types'                 => 'favorites',
				'include_post_children' => false,
				'user_id'               => $this->get_id(),
				'post_id'               => $object_id,
				'per_page'              => 1,
				'no_found_rows'         => true,
			)
		);

		$ret = $query->has_results();

		/**
		 * Filter object favorite boolean value prior to returning.
		 *
		 * The dynamic portion of this filter, `{$object_type}`, refers to the Lesson.
		 *
		 * @since 7.5.0
		 *
		 * @param array|false  $ret         Array of favorite data or `false` if no favorite is found.
		 * @param int          $object_id   WP Post ID of the object to mark/unmark as favorite.
		 * @param string       $object_type The object type, currently only 'lesson'.
		 * @param LLMS_Student $instance    The Student Instance
		 */
		return apply_filters( 'llms_is_' . $object_type . '_favorite', $ret, $object_id, $object_type, $this );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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