• LifterLMS
  • Knowledge Base
  • Academy
  • Blog
  • Podcast
  • Contributors
  • My Account

LifterLMS LifterLMS

  • Code Reference
  • REST API
  • LLMS-CLI

Code Reference

Skip to content
Filter by type:
Search
Browse: Home / Code Reference / Classes / LLMS_User_Postmeta / LLMS_User_Postmeta::get_description()

LLMS_User_Postmeta::get_description( string $context = 'course' )

Get a string used to describe the postmeta item.

Contents

  • Parameters
  • Return
  • Source
  • Related
    • Uses
  • Changelog
  • User Contributed Notes

Parameters #Parameters

$context

(string) (Optional) Display context either "course" or "student".

Default value: 'course'


Top ↑

Return #Return

(string)


Top ↑

Source #Source

File: includes/models/model.llms.user.postmeta.php

	public function get_description( $context = 'course' ) {

		$key = $this->get( 'meta_key' );

		$student = $this->get_student();
		$name    = $student ? $student->get( 'display_name' ) : __( '[Deleted]', 'lifterlms' );

		$post      = llms_get_post( $this->get( 'post_id' ) );
		$label     = is_a( $post, 'LLMS_Post_Model' ) ? strtolower( $post->get_post_type_label() ) : __( 'quiz', 'lifterlms' );
		$post_name = ( 'course' === $context ) ? $label : sprintf( '%1$s "%2$s"', $label, get_the_title( $this->get( 'post_id' ) ) );

		$string = '';

		switch ( $key ) {

			case '_achievement_earned':
				$string = sprintf( __( '%1$s earned the achievement "%2$s"', 'lifterlms' ), $name, get_the_title( $this->get( 'meta_value' ) ) );

				break;

			case '_certificate_earned':
				$string = sprintf( __( '%1$s earned the certificate "%2$s"', 'lifterlms' ), $name, get_the_title( $this->get( 'meta_value' ) ) );

				break;

			case '_email_sent':
				$string = sprintf( __( 'Email "%1$s" was sent to %2$s', 'lifterlms' ), get_the_title( $this->get( 'meta_value' ) ), $name );

				break;

			case '_enrollment_trigger':
				$string = sprintf( __( '%1$s purchased the %2$s', 'lifterlms' ), $name, $post_name );

				break;

			case '_status':
				if ( 'enrolled' === $this->get( 'meta_value' ) ) {
					$string = sprintf( __( '%1$s enrolled into the %2$s', 'lifterlms' ), $name, $post_name );
				} else {
					$string = sprintf( __( '%1$s unenrolled from the %2$s', 'lifterlms' ), $name, $post_name );
				}

				break;

			case '_is_complete':
				$string = sprintf( __( '%1$s completed the %2$s', 'lifterlms' ), $name, $post_name );

				break;

		}// End switch().

		return $string;

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Related #Related

Uses #Uses

Uses
Uses Description
includes/models/model.llms.user.postmeta.php: LLMS_User_Postmeta::get_student()

Retrieve a student obj for the meta item.

includes/llms.functions.core.php: llms_get_post()

Retrieve the LLMS Post Model for a give post by ID or WP_Post Object


Top ↑

Changelog #Changelog

Changelog
Version Description
3.15.0 Introduced.

Top ↑

User Contributed Notes #User Contributed Notes

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

© 2014 - 2023 LifterLMS · Privacy Policy · Terms and Conditions

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.