lifterlms_template_my_memberships_loop( LLMS_Student $student = null )

Get course tiles for a student’s memberships


Parameters Parameters

$student

(LLMS_Student) (Optional) LLMS_Student (current student if none supplied). Default null.

Default value: null


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/functions/llms.functions.templates.dashboard.php

if ( ! function_exists( 'llms_template_my_favorites_loop' ) ) {

	/**
	 * Get student's favorites.
	 *
	 * @since 7.5.0
	 *
	 * @param LLMS_Student $student   Optional. LLMS_Student (current student if none supplied). Default `null`.
	 * @param array        $favorites Optional. Array of favorites (current student's favorites if none supplied). Default `null`.
	 * @return void
	 */
	function llms_template_my_favorites_loop( $student = null, $favorites = null ) {

		$student = llms_get_student( $student );
		if ( ! $student ) {
			return;
		}

		$favorites = $favorites ?? $student->get_favorites();

		if ( ! $favorites ) {

			printf( '<p>%s</p>', esc_html__( 'No favorites found.', 'lifterlms' ) );

		} else {

			// Adding Parent Course IDs in Favorites for each lesson.
			foreach ( $favorites as $key => $favorite ) {
				$lesson                  = new LLMS_Lesson( $favorite->post_id );
				$favorite->parent_course = $lesson->get( 'parent_course' );
			}

			// Grouping Favorites by Parent Course ID.
			$favorites = array_reduce(
				$favorites,
				function ( $carry, $item ) {
					$carry[ $item->parent_course ][] = $item;
					return $carry;


Top ↑

Changelog Changelog

Changelog
Version Description
3.14.8 Unknown.
3.14.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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