Wpum_Tokens::wpum_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_possible_tokens( $tokens = array(), $args = array() ) {
		$form_id      = absint( $args['value'] );
		$trigger_meta = $args['meta'];

		if ( empty( $form_id ) ) {
			return $tokens;
		}

		$form = new \WPUM_Registration_Form( $form_id );

		if ( ! $form->exists() ) {
			return $tokens;
		}

		if ( $form->exists() ) {
			$fields        = array();
			$stored_fields = $form->get_fields();

			if ( is_array( $stored_fields ) && ! empty( $stored_fields ) ) {
				foreach ( $stored_fields as $field ) {
					$stored_field = new \WPUM_Field( $field );
					if ( $stored_field->exists() ) {
						$fields[] = [
							'tokenId'         => $stored_field->get_primary_id(),
							'tokenName'       => $stored_field->get_name(),
							'tokenType'       => $stored_field->get_type(),
							'tokenIdentifier' => $trigger_meta,
						];
					}
				}
			}
		}

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

		return $tokens;
	}