Wpum_Tokens::parse_wpum_tokens( $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/wp-user-manager/tokens/wpum-tokens.php

	public function parse_wpum_tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
		if ( $pieces ) {
			if ( in_array( 'WPUMREGFORM', $pieces ) || in_array( 'WPUMUSERREGISTERED', $pieces )
			     || in_array( 'WPUMUSERDESCRIPTION', $pieces ) || in_array( 'WPUMDESCRIPTIONUPDATED', $pieces )
			) {
				global $wpdb;
				$trigger_id     = $pieces[0];
				$trigger_meta   = $pieces[2];
				$trigger_log_id = isset( $replace_args['trigger_log_id'] ) ? absint( $replace_args['trigger_log_id'] ) : 0;
				$entry          = $wpdb->get_var( "SELECT meta_value
													FROM {$wpdb->prefix}uap_trigger_log_meta
													WHERE meta_key = '{$trigger_meta}'
													AND automator_trigger_log_id = {$trigger_log_id}
													AND automator_trigger_id = {$trigger_id}
													LIMIT 0,1" );

				$value = maybe_unserialize( $entry );
			} elseif ( in_array( 'WPUMUSERPPHOTO', $pieces ) || in_array( 'WPUMPPUPDATED', $pieces )
			           || in_array( 'WPUMUSERPPHOTOR', $pieces ) || in_array( 'WPUMPPREMOVED', $pieces )
			           || in_array( 'WPUMUSERCOVER', $pieces ) || in_array( 'WPUMCPUPDATED', $pieces )
			           || in_array( 'WPUMUSERPCOVERR', $pieces ) || in_array( 'WPUMPCREMOVED', $pieces )
			) {
				if ( $pieces[2] == 'WPUMPPUPDATED' || $pieces[2] == 'WPUMPPREMOVED' || $pieces[2] == 'WPUMCPUPDATED' ||
				     $pieces[2] == 'WPUMPCREMOVED' ) {
					global $wpdb;
					$trigger_id     = $pieces[0];
					$trigger_meta   = $pieces[2];
					$trigger_log_id = isset( $replace_args['trigger_log_id'] ) ? absint( $replace_args['trigger_log_id'] ) : 0;
					$entry          = $wpdb->get_var( "SELECT meta_value
													FROM {$wpdb->prefix}uap_trigger_log_meta
													WHERE meta_key = '{$trigger_meta}'
													AND automator_trigger_log_id = {$trigger_log_id}
													AND automator_trigger_id = {$trigger_id}
													LIMIT 0,1" );

					$value = maybe_unserialize( $entry );
				} else {
					$user  = get_user_by( 'id', $user_id );
					$field = $pieces[2];

					$entry = $this->get_field_value( $user, $field );
					$value = maybe_unserialize( $entry );
				}

			}
		}

		return $value;
	}