• 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_Shortcode_User_Info / LLMS_Shortcode_User_Info::get_output()

LLMS_Shortcode_User_Info::get_output()

Retrieve the actual content of the shortcode

Contents

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

Description #Description

$atts & $content are both filtered before being passed to get_output() output is filtered so the return of get_output() doesn’t need its own filter


Top ↑

Return #Return

(string)


Top ↑

Source #Source

File: includes/shortcodes/class-llms-shortcode-user-info.php

	protected function get_output() {

		/**
		 * Filters the user used to retrieve user information displayed by the [llms-user] shortcode
		 *
		 * @since 5.0.0
		 *
		 * @param integer $user_id The WP_User ID of the currently logged-in user or `0` if no user logged in.
		 */
		$user_id = apply_filters( 'llms_user_info_shortcode_user_id', get_current_user_id() );
		$key     = $this->get_attribute( 'key' );
		$default = $this->get_attribute( 'or' );

		if ( in_array( $key, $this->get_blocklist(), true ) ) {
			return '';
		}

		// No user OR no key provided.
		if ( ! $user_id || ! $key ) {
			return $default;
		}

		$user = new WP_User( $user_id );
		$val  = $user->exists() ? $user->get( $key ) : null;

		return ! empty( $val ) && is_scalar( $val ) ? $val : $default;

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Related #Related

Uses #Uses

Uses
Uses Description
includes/shortcodes/class-llms-shortcode-user-info.php: llms_user_info_shortcode_user_id

Filters the user used to retrieve user information displayed by the [llms-user] shortcode

includes/shortcodes/class-llms-shortcode-user-info.php: LLMS_Shortcode_User_Info::get_blocklist()

Retrieves a list of keys that cannot be displayed by the shortcode.


Top ↑

Changelog #Changelog

Changelog
Version Description
5.0.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.