Wpum_Tokens::wpum_profile_possible_tokens( array $tokens = array(), array $args = array() )


Parameters Parameters

$tokens

(array) (Optional)

Default value: array()

$args

(array) (Optional)

Default value: array()


Top ↑

Return Return

(array)


Source Source

File: src/integrations/wp-user-manager/tokens/wpum-tokens.php

	public function wpum_profile_possible_tokens( $tokens = array(), $args = array() ) {
		$trigger_meta = $args['meta'];

		$account_fields = WPUM()->fields->get_fields(
			[
				'group_id' => 1,
				'orderby'  => 'field_order',
				'order'    => 'ASC',
			]
		);

		foreach ( $account_fields as $field ) {

			$field = new \WPUM_Field( $field );

			if ( $field->exists() && $field->get_meta( 'editing' ) == 'public' &&
			     $field->get_primary_id() !== 'user_password' ) {

				// Skip the avatar field if disabled.
				if ( $field->get_primary_id() == 'user_avatar' && ! wpum_get_option( 'custom_avatars' ) ) {
					continue;
				}
				$fields[] = [
					'tokenId'         => $field->get_primary_id(),
					'tokenName'       => $field->get_name(),
					'tokenType'       => $field->get_type(),
					'tokenIdentifier' => $trigger_meta,
				];
			}
		}

		$tokens = array_merge( $tokens, $fields );

		return $tokens;
	}