From 365f5aefad7884b597a69f58de965fa8f74eb345 Mon Sep 17 00:00:00 2001
From: davidperezgar
' . esc_html__( 'No modules found. Check your API credentials and try reconnecting.', 'formscrm' ) . '
- crmlib->list_modules( $cf7_crm );
- if ( empty( $modules ) ) {
- echo '
@@ -186,11 +178,15 @@ public function settings_add_crm( $args ) {
if ( ! empty( $this->crmlib ) ) {
$login_crm = $this->crmlib->login( $cf7_crm );
+ if ( is_array( $login_crm ) && isset( $login_crm['status'] ) && 'error' === $login_crm['status'] ) {
+ return;
+ }
+
if ( is_array( $login_crm ) && isset( $login_crm['status'] ) && 'error' === $login_crm['status'] ) {
echo '
' . esc_html( $login_crm['message'] ) . '
'; return; } - if ( true !== $login_crm && false !== $login_crm ) { + if ( false === $login_crm ) { return; } } @@ -289,9 +285,18 @@ public function crm_process_entry( $contact_form ) { $submission = WPCF7_Submission::get_instance(); $crm_type = ! empty( $cf7_crm['fc_crm_type'] ) ? sanitize_text_field( $cf7_crm['fc_crm_type'] ) : ''; + $form_info = array( + 'form_type' => 'contactform7', + 'form_type_title' => 'Contact Form 7', + 'form_id' => $contact_form->id(), + 'form_name' => $contact_form->title(), + ); + // Create contact in CRM. $this->crmlib = formscrm_get_api_class( $crm_type ); if ( empty( $this->crmlib ) ) { + /* translators: %s: CRM type slug */ + formscrm_alert_error( $crm_type, sprintf( __( 'CRM class not found for type: %s', 'formscrm' ), $crm_type ), array(), '', '', $form_info ); return; } $merge_vars = self::get_merge_vars( $cf7_crm, $submission->get_posted_data() ); @@ -301,13 +306,6 @@ public function crm_process_entry( $contact_form ) { $url = isset( $response_result['url'] ) ? $response_result['url'] : ''; $query = isset( $response_result['query'] ) ? $response_result['query'] : ''; - $form_info = array( - 'form_type' => 'contactform7', - 'form_type_title' => 'Contact Form 7', - 'form_id' => $contact_form->id(), - 'form_name' => $contact_form->title(), - ); - formscrm_alert_error( $cf7_crm['fc_crm_type'], 'Error ' . $response_result['message'], $merge_vars, $url, $query, $form_info ); } } @@ -338,11 +336,6 @@ public static function get_merge_vars( $cf7_crm, $submitted_data ) { $value = implode( ',', $value ); } - // Normalize boolean CRM fields to true/false as required by the API. - if ( in_array( $crm_key, array( 'gdpr_accept', 'disclaimer' ), true ) ) { - $value = ! empty( $value ); - } - // Process dynamic values (shortcodes). $value = self::fill_dynamic_value( $value, $submitted_data );