diff --git a/README.md b/README.md index f671c49..37e489f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ Yes, all the other form widget integrations will be available. ## Changelog +### 1.3.0 - 19-11-2021 +* Added Firstname attribute mapping +* Added Lastname attribute mapping +* Tested Elementor up to 3.4.8 + ### 1.2.0 - 13-11-2021 * Added GDPR checkbox functionality * Added dynamic tags to the double optin field diff --git a/includes/class-sendinblue-integration-action.php b/includes/class-sendinblue-integration-action.php index 675bd2e..726c45b 100644 --- a/includes/class-sendinblue-integration-action.php +++ b/includes/class-sendinblue-integration-action.php @@ -163,13 +163,26 @@ public function register_settings_section( $widget ) { ] ); + $widget->add_control( + 'sendinblue_name_attribute_field', + [ + 'label' => __( 'Name Field attribute (Optional)', 'sendinblue-elementor-integration' ), + 'type' => \Elementor\Controls_Manager::TEXT, + 'placeholder' => 'FIRSTNAME', + 'separator' => 'before', + 'description' => __( 'Enter the firstname attribute name - you can find this under contact attributes settings in Sendinblue - If this field is not set it wil default to FIRSTNAME', 'sendinblue-elementor-integration' ), + 'dynamic' => [ + 'active' => true, + ], + ] + ); + $widget->add_control( 'sendinblue_name_field', [ 'label' => __( 'Name Field ID (Optional)', 'sendinblue-elementor-integration' ), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => 'name', - 'separator' => 'before', 'description' => __( 'Enter the name field id - you can find this under the name field advanced tab', 'sendinblue-elementor-integration' ), 'dynamic' => [ 'active' => true, @@ -177,13 +190,26 @@ public function register_settings_section( $widget ) { ] ); + $widget->add_control( + 'sendinblue_last_name_attribute_field', + [ + 'label' => __( 'Lastname Field attribute (Optional)', 'sendinblue-elementor-integration' ), + 'type' => \Elementor\Controls_Manager::TEXT, + 'placeholder' => 'LASTNAME', + 'separator' => 'before', + 'description' => __( 'Enter the lastname attribute name - you can find this under contact attributes settings in Sendinblue - If this field is not set it wil default to LASTNAME', 'sendinblue-elementor-integration' ), + 'dynamic' => [ + 'active' => true, + ], + ] + ); + $widget->add_control( 'sendinblue_last_name_field', [ 'label' => __( 'Lastname Field ID (Optional)', 'sendinblue-elementor-integration' ), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => 'lastname', - 'separator' => 'before', 'description' => __( 'Enter the lastname field id - you can find this under the lastname field advanced tab', 'sendinblue-elementor-integration' ), 'dynamic' => [ 'active' => true, @@ -212,7 +238,9 @@ public function on_export( $element ) { $element['sendinblue_gdpr_checkbox_field'], $element['sendinblue_list'], $element['sendinblue_email_field'], + $element['sendinblue_name_attribute_field'], $element['sendinblue_name_field'], + $element['sendinblue_last_name_attribute_field'], $element['sendinblue_last_name_field'] ); @@ -287,6 +315,22 @@ public function run( $record, $ajax_handler ) { } } + // Sendinblue attribute names - Firstname + if (empty($settings['sendinblue_name_attribute_field'])) { + $sendinblueattributename = "FIRSTNAME"; + } + else { + $sendinblueattributename = $settings['sendinblue_name_attribute_field']; + } + + // Sendinblue attribute names - Lastname + if (empty($settings['sendinblue_last_name_attribute_field'])) { + $sendinblueattributelastname = "LASTNAME"; + } + else { + $sendinblueattributelastname = $settings['sendinblue_last_name_attribute_field']; + } + if ($doubleoptin == "yes") { //Send data to Sendinblue Double optin $dpubleoptin = wp_remote_post( 'https://api.sendinblue.com/v3/contacts/doubleOptinConfirmation', array( @@ -299,7 +343,7 @@ public function run( $record, $ajax_handler ) { 'api-key' => $settings['sendinblue_api'], 'content-Type' => 'application/json', ], - 'body' => json_encode(["attributes" => [ "FIRSTNAME" => $fields[$settings['sendinblue_name_field']], "LASTNAME" => $fields[$settings['sendinblue_last_name_field']] ], "includeListIds" => [(int)$settings['sendinblue_list']], "templateId" => (int)$settings['sendinblue_double_optin_template'], "redirectionUrl" => $settings['sendinblue_double_optin_redirect_url'], "email" => $fields[$settings['sendinblue_email_field']]]) + 'body' => json_encode(["attributes" => [ $sendinblueattributename => $fields[$settings['sendinblue_name_field']], $sendinblueattributelastname => $fields[$settings['sendinblue_last_name_field']] ], "includeListIds" => [(int)$settings['sendinblue_list']], "templateId" => (int)$settings['sendinblue_double_optin_template'], "redirectionUrl" => $settings['sendinblue_double_optin_redirect_url'], "email" => $fields[$settings['sendinblue_email_field']]]) ) ); } @@ -315,7 +359,7 @@ public function run( $record, $ajax_handler ) { 'api-key' => $settings['sendinblue_api'], 'content-Type' => 'application/json', ], - 'body' => json_encode(["attributes" => [ "FIRSTNAME" => $fields[$settings['sendinblue_name_field']], "LASTNAME" => $fields[$settings['sendinblue_last_name_field']] ], "updateEnabled" => true, "listIds" => [(int)$settings['sendinblue_list']], "email" => $fields[$settings['sendinblue_email_field']]]) + 'body' => json_encode(["attributes" => [ $sendinblueattributename => $fields[$settings['sendinblue_name_field']], $sendinblueattributelastname => $fields[$settings['sendinblue_last_name_field']] ], "updateEnabled" => true, "listIds" => [(int)$settings['sendinblue_list']], "email" => $fields[$settings['sendinblue_email_field']]]) ) ); } diff --git a/readme.txt b/readme.txt index 2b7ccda..7316702 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: sendinblue, elementor, elementor pro, forms, integration, marketing, lists Requires at least: 5.0 Tested up to: 5.8.2 Requires PHP: 5.4 -Stable tag: 1.2.0 +Stable tag: 1.3.0 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -51,6 +51,11 @@ Yes, all the other form widget integrations will be available. == Changelog == += 1.3.0 - 2021-11-19 = +* Added Firstname attribute mapping +* Added Lastname attribute mapping +* Tested Elementor up to 3.4.8 + = 1.2.0 - 2021-11-13 = * Added GDPR checkbox functionality * Added dynamic tags to the double optin field diff --git a/sendinblue-elementor-integration.php b/sendinblue-elementor-integration.php index 0d24f19..5d798a6 100644 --- a/sendinblue-elementor-integration.php +++ b/sendinblue-elementor-integration.php @@ -5,8 +5,8 @@ * Description: Easily connect and send data to sendinblue from elementor forms. * Author: Webtica * Author URI: https://webtica.be/ - * Version: 1.2.0 - * Elementor tested up to: 3.4.7 + * Version: 1.3.0 + * Elementor tested up to: 3.4.8 * Elementor Pro tested up to: 3.5.1 */