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_Student::update_favorite_status( string $status, int $object_id, string $object_type )

Triggers actions for favorite/unfavorite.


Description Description

Update the favorite status of a lesson for the current student.
Inserts / updates necessary user postmeta data.


Top ↑

Parameters Parameters

$status

(string) (Required) New status to update to, either "favorite" or "unfavorite".

$object_id

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

$object_type

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


Top ↑

Return Return

(bool)


Top ↑

Source Source

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

	private function update_favorite_status( $status, $object_id, $object_type ) {

		$student_id = $this->get_id();

		/**
		 * Fires before a student's object favorite status is updated.
		 *
		 * The dynamic portion of this hook, `$status`, refers to the new completion status of the object,
		 * either "favorite" or "unfavorite".
		 *
		 * @since 7.5.0
		 *
		 * @param int    $student_id  WP_User ID of the student.
		 * @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'.
		 */
		do_action( "before_llms_mark_{$status}", $student_id, $object_id, $object_type );

		// Insert / Remove meta data.
		if ( 'favorite' === $status ) {
			$this->insert_favorite_postmeta( $object_id );
		} elseif ( 'unfavorite' === $status ) {
			$this->remove_favorite_postmeta( $object_id );
		}

		/**
		 * Hook that fires when a student's favorite status is updated for any object.
		 *
		 * The dynamic portion of this hook, `$status`, refers to the new favorite status of the object,
		 * either "favorite" or "unfavorite".
		 *
		 * @since 7.5.0
		 *
		 * @param int    $student_id  WP_User ID of the student.
		 * @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'.
		 */
		do_action( "llms_mark_{$status}", $student_id, $object_id, $object_type );

		/**
		 * Hook that fires when a student's favorite status is updated for a specific object type.
		 *
		 * The dynamic portion of this hook, `$object_type` refers to the WP_Post post_type of the object
		 * which the student's completion status is being updated for.
		 *
		 * The dynamic portion of this hook, `$status`, refers to the new completion status of the object,
		 * either "favorite" or "unfavorite".
		 *
		 * @since 7.5.0
		 *
		 * @param int $student_id WP_User ID of the student.
		 * @param int $object_id  WP_Post ID of the object.
		 */
		do_action( "lifterlms_{$object_type}_{$status}d", $student_id, $object_id );

		return true;
	}


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.