Noptin_Email_Action::run( Noptin_Subscriber $subscriber, Noptin_Automation_Rule $rule, array $args )

Sends an email to the subscriber.


Parameters Parameters

$subscriber

(Noptin_Subscriber) (Required) The subscriber.

$rule

(Noptin_Automation_Rule) (Required) The automation rule used to trigger the action.

$args

(array) (Required) Extra arguments passed to the action.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/automation-rules/actions/class-noptin-email-action.php

    public function run( $subscriber, $rule, $args ) {

        $email_content = $rule->action_settings['email_content'];
        $email_subject = $rule->action_settings['email_subject'];
        $email_preview = isset( $rule->action_settings['email_preview'] ) ? $rule->action_settings['email_preview'] : '';

        $merge_tags = get_noptin_subscriber_merge_fields(  $subscriber->id  );
        
        if ( is_array( $args ) ) {

            foreach ( $args as $key => $value ) {

                if ( is_scalar( $value ) ) {
                    $merge_tags[ $key ] = $value;
                }

            }
        }

		$item  = array(
			'subscriber_id' 	=> $subscriber->id,
			'email' 			=> $subscriber->email,
			'email_body'	    => wp_kses_post( stripslashes_deep( $email_content ) ),
			'email_subject' 	=> sanitize_text_field( stripslashes_deep( $email_subject ) ),
			'preview_text'  	=> sanitize_text_field( stripslashes_deep( $email_preview ) ),
            'merge_tags'		=> $merge_tags,
            'permission_text'   => isset( $rule->action_settings['permission_reminder'] ) ? $rule->action_settings['permission_reminder'] : '',
            'footer_text'       => isset( $rule->action_settings['email_footer'] ) ? $rule->action_settings['email_footer'] : '',
		);

		$item = apply_filters( 'noptin_email_action_email_details', $item, $subscriber, $rule, $args );

        // Sends the email in the background.
        return noptin()->mailer->prepare_then_send( $item );

    }


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.3.0Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation