learndash_usermeta_shortcode_available_fields

apply_filters( 'learndash_usermeta_shortcode_available_fields',  array $available_fields,  array $attributes )

Filters the usermeta shortcode available fields.


Description #

Added logic to allow protect certain user meta fields. The default fields is based on some of the fields returned via get_userdata().


Parameters #

$available_fields

(array) An array of available shortcode fields.

$attributes

(array) An array of attributes to provide context for the filter.


Source #

File: includes/ld-users.php


Examples #

 <?php
/**
 * Example usage for learndash_usermeta_shortcode_available_fields filter.
 */
add_filter(
	'learndash_usermeta_shortcode_available_fields',
	function( $available_fields = array(), $attr = array() ) {
		if ( ! array_key_exists( 'my_custom_usermeta_field', $available_fields ) ) {
			$available_fields['my_custom_usermeta_field'] = 'My Custom User Field';
		}

		// Always return $available_fields
		return $available_fields;

	},
	10,
	2
);
 

Changelog #

Changelog
Version Description
2.4.0 Introduced.