Noptin_Contact_Form_7::process_form( WPCF7_ContactForm $contact_form, array $result )


Parameters Parameters

$contact_form

(WPCF7_ContactForm) (Required) The contact form being edited.

$result

(array) (Required) The result of the submission.


Top ↑

Source Source

File: includes/integrations/class-noptin-contact-form-7.php

    public function process_form( $contact_form, $result ) {

		// Check if we're in demo mode.
		if ( $contact_form->in_demo_mode() ) {
			return;
		}

		// Check the submission status
		if ( empty( $result['status'] ) || ! in_array( $result['status'], array( 'mail_sent', 'mail_failed' ), true ) ) {
			return;
		}

		// Prepare args.
        $submission  = WPCF7_Submission::get_instance();
        $posted_data = $submission->get_posted_data();

        // Get our settings for the form.
		$settings    = get_post_meta( $contact_form->id(), 'noptin_settings', true );
		$settings    = is_array( $settings ) ? $settings : array();

		// Retrieve field maps.
		$mapped_fields = isset( $settings['custom_fields'] ) ? $settings['custom_fields'] : array();

		// Prepare Noptin Fields.
		$noptin_fields = $this->map_fields( $posted_data, $mapped_fields );

		// Abort if newsletter checkbox was not checked.
		$conditional = isset( $mapped_fields['GDPR_consent'] ) ? $mapped_fields['GDPR_consent'] : '';
		if ( ! empty( $mapped_fields['GDPR_consent'] ) && empty( $noptin_fields[ 'GDPR_consent' ] ) ) {
			return;
		}
	
		// We need an email.
		if ( empty( $noptin_fields['email'] ) ) {
			return;
		}

		// Add integration data.
		$noptin_fields['integration_data'] = compact( 'contact_form', 'posted_data' );

		// Filter the subscriber fields.
		$noptin_fields = apply_filters( 'noptin_contact_form_7_integration_new_subscriber_fields', $noptin_fields, $this );

		// Register the subscriber.
		add_noptin_subscriber( $noptin_fields );

	}


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