Cf_Tokens::parse_cf_token( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(Required)

$replace_args

(Required)


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/caldera-forms/tokens/cf-tokens.php

	public function parse_cf_token( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
		if ( $pieces ) {
			if ( in_array( 'CFFORMS', $pieces ) ) {

				$token_info = explode( '|', $pieces[2] );
				$form_id    = (int) sanitize_text_field( $token_info[0] );
				$meta_key   = sanitize_text_field( $token_info[1] );
				if ( isset( $_POST['formId'] ) && absint( $_POST['formId'] ) === $form_id && isset( $_POST[ $meta_key ] ) ) {
					if ( is_array( $_POST[ $meta_key ] ) ) {
						$value = sanitize_text_field( implode( ', ', $_POST[ $meta_key ] ) );
					} else {
						$value = sanitize_text_field( $_POST[ $meta_key ] );
					}
				}
			}
		}

		return $value;
	}