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

LifterLMS LifterLMS

Code Reference

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

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

Retrieve a link for the item on the admin panel

Contents

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

Description #Description


Parameters #Parameters

$context

(string) (Optional) display context [course|student]

Default value: 'course'


Top ↑

Return #Return

(string)


Top ↑

Source #Source

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

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

		switch ( $this->get( 'meta_key' ) ) {

			case '_achievement_earned':
				$achievement = new LLMS_User_Achievement( $this->get( 'meta_value' ) );
				$url = get_edit_post_link( $achievement->get( 'achievement_template' ) );
			break;

			case '_certificate_earned':
				$certificate = new LLMS_User_Certificate( $this->get( 'meta_value' ) );
				$url = get_edit_post_link( $certificate->get( 'certificate_template' ) );
			break;

			case '_email_sent':
				$url = get_edit_post_link( $this->get( 'meta_value' ) );
			break;

			case '_enrollment_trigger':
				$url = get_edit_post_link( str_replace( 'order_', '', $this->get( 'meta_value' ) ) );
			break;

			default:

				$student = $this->get_student();
				if ( ! $student ) {
					return '';
				}

				$course = false;
				if ( 'course' === get_post_type( $this->get( 'post_id' ) ) ) {
					$course = llms_get_post( $this->get( 'post_id' ) );
				} else {
					$course = llms_get_post_parent_course( $this->get( 'post_id' ) );
				}

				if ( $course ) {
					$url = LLMS_Admin_Reporting::get_current_tab_url( array(
						'course_id' => $course->get( 'id' ),
						'stab' => 'courses',
						'student_id' => $student->get_id(),
						'tab' => 'students',
					) );
				}
		}// End switch().

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Changelog #Changelog

Changelog
Version Description
3.15.0 Introduced.

Top ↑

Related #Related

Top ↑

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

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

Retrieve the parent course for a section, lesson, or quiz

includes/admin/reporting/class.llms.admin.reporting.php: LLMS_Admin_Reporting::get_current_tab_url()

Top ↑

User Contributed Notes #User Contributed Notes

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





Permalink:
© 2014 - 2019 LifterLMS · Privacy Policy · Terms and Conditions