WP_SENDEMAIL::process_action( $user_id,  $action_data,  $recipe_id,  $args,  $parsed )


Parameters Parameters

$user_id

(Required)

$action_data

(Required)

$recipe_id

(Required)

$args

(Required)

$parsed

(Required)


Top ↑

Return Return

(Uncanny_Automatorvoid.)


Source Source

File: src/integrations/wp/actions/wp-sendemail.php

	protected function process_action( int $user_id, array $action_data, int $recipe_id, array $args, $parsed ) {

		$body_text = $parsed['EMAILBODY'] ?? '';

		if ( false !== strpos( $body_text, '{{reset_pass_link}}' ) ) {
			$reset_pass = ! is_null( $this->key ) ? $this->key : Automator()->parse->generate_reset_token( $user_id );
			$body       = str_replace( '{{reset_pass_link}}', $reset_pass, $body_text );
		} else {
			$body = $body_text;
		}

		$data = array(
			'to'        => $parsed['EMAILTO'] ?? '',
			'from'      => $parsed['EMAILFROM'] ?? '',
			'from_name' => $parsed['EMAILFROMNAME'] ?? '',
			'cc'        => $parsed['EMAILCC'] ?? '',
			'bcc'       => $parsed['EMAILBCC'] ?? '',
			'subject'   => $parsed['EMAILSUBJECT'] ?? '',
			'body'      => $body,
			'content'   => $this->get_content_type(),
			'charset'   => $this->get_charset(),
		);

		$this->set_mail_values( $data );

		$mailed = $this->send_email();

		// Set $this->set_error_message(); and complete the action automatically. May be use return true / false.
		if ( false === $mailed && ! empty( $this->get_error_message() ) ) {

			$error_message                       = $this->get_error_message();
			$action_data['complete_with_errors'] = true;
			Automator()->complete->action( $user_id, $action_data, $recipe_id, $error_message );

		}

		Automator()->complete->action( $user_id, $action_data, $recipe_id );

	}