• 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_link()

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

Retrieve a link for the item on the admin panel

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_link( $context = 'course' ) {

		$url = '';

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

			case '_achievement_earned':
			case '_certificate_earned':
			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',
						)
					);
				}
		}

		return $url;

	}

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

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()

Returns an admin URL with the given arguments added as query variables.


Top ↑

Changelog #Changelog

Changelog
Version Description
6.0.0 Don't use deprecated achievement and certificate meta data. Combined redundant cases into a single case. Fixed return value.
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.