Wp_Tokens::parse_anonusercreated_token( $value,  $pieces,  $recipe_id,  $trigger_data, int $user_id,  $replace_args = array() )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(int) (Required)

$replace_args

(Optional)

Default value: array()


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/wp/tokens/wp-tokens.php

	public function parse_anonusercreated_token( $value, $pieces, $recipe_id, $trigger_data, $user_id = 0, $replace_args ) {
		$piece = 'WPPOSTCOMMENTS';
		if ( $pieces ) {
			if ( in_array( $piece, $pieces ) ) {


				if ( $trigger_data ) {
					foreach ( $trigger_data as $trigger ) {
						global $wpdb;
						$meta_field = 'WPPOSTCOMMENTS';
						$trigger_id = $trigger['ID'];
						$meta_value = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->prefix}uap_trigger_log_meta WHERE meta_key LIKE '%{$meta_field}%' AND automator_trigger_id = {$trigger_id} ORDER BY ID DESC LIMIT 0,1" );
						if ( ! empty( $meta_value ) ) {
							$post_id = maybe_unserialize( $meta_value );
						} else {
							$post_id = $trigger['meta']['WPPOSTCOMMENTS'];
						}

						$post = get_post( $post_id );
						if ( ! empty( $post ) ) {
							if ( 'authorname' === $pieces[2] ) {
								$value = get_the_author_meta( 'display_name', $post->post_author );
							}
							if ( 'authoremail' === $pieces[2] ) {
								$value = get_the_author_meta( 'email', $post->post_author );
							}
							if ( 'WPPOSTTYPES' === $pieces[2] ) {
								$value = get_post_type( $post );
							}
						}
					}
				}
			}
		}

		return $value;
	}