settingsDTO->getPixels() ) < 1 ) { return; } $this->setupEventListeners(); } public function setupEventListeners() { add_action( 'ninja_forms_after_submission', array( $this, 'contactForm' ), 10, 1 ); } public function contactForm( $formData ) { $formSettings = $this->settingsDTO->getForm( $formData['form_id'], $this->pluginName ); // Send only matched fields $posted_data = $formData['fields_by_key']; $eventDto = new EventDTO( EventDTO::EVENT_LEAD ); $contentDto = new ContentDTO(); foreach ( $formSettings->getMatches() as $match ) { $val = $posted_data[ $match->getFormField() ]['value']; $this->assignMatchedValue( $val, $match, $eventDto, $contentDto ); } $this->sendEvent( $eventDto ); } public function getForms() { if ( ! function_exists( 'Ninja_Forms' ) ) { return; } $forms = array(); foreach ( Ninja_Forms()->form()->get_forms() as $form ) { $formId = $form->get_id(); $fields = array(); foreach ( Ninja_Forms()->form( $formId )->get_fields() as $field ) { $fields[] = array( 'name' => $field->get_setting( 'key' ), 'label' => $field->get_setting( 'label' ), 'type' => $field->get_setting( 'type' ), ); } $forms[] = array( 'id' => $formId, 'title' => $form->get_setting( 'form_title' ), 'plugin' => $this->pluginName, 'fields' => $fields, ); } return $forms; } } }