From 4737561448a98299c455f833413ef9f08da98612 Mon Sep 17 00:00:00 2001 From: Jonathan DAHAN Date: Tue, 22 Mar 2022 15:36:59 +0100 Subject: [PATCH] Enchance description, increment to release 1.0.2, Add a fourth field "Custom" --- ActionSubscriber.php | 14 +++++++++++++- README.md | 6 +++++- readme.txt | 7 ++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ActionSubscriber.php b/ActionSubscriber.php index 1c5133f..492ee45 100644 --- a/ActionSubscriber.php +++ b/ActionSubscriber.php @@ -39,7 +39,8 @@ public function run($record, $ajax_handler) $MJF_contactdata1 = ['Data' => [['Name' => $settings['MJF_name_field'], 'Value' => $fields['name'], ]]]; $MJF_contactdata2 = ['Data' => [['Name' => $settings['MJF_firstname_field'], 'Value' => $fields['firstname'], ]]]; $MJF_contactdata3 = ['Data' => [['Name' => $settings['MJF_phone_field'], 'Value' => $fields['phone'], ]]]; - + $MJF_contactdata4 = ['Data' => [['Name' => $settings['MJF_custom_field'], 'Value' => $fields['custom'], ]]]; + $MJF_API = MAILJET_API; $MJF_SECRET = MAILJET_SECRET; $auth = base64_encode($MJF_API . ':' . $MJF_SECRET); @@ -58,6 +59,10 @@ public function run($record, $ajax_handler) 'Authorization' => "Basic $auth", 'Content-Type' => 'application/json' ) , 'body' => json_encode($MJF_contactdata3) , ]; + $MJF_contactdata4_args = ['method' => 'PUT', 'headers' => array( + 'Authorization' => "Basic $auth", + 'Content-Type' => 'application/json' + ) , 'body' => json_encode($MJF_contactdata4) , ]; $MJF_responsecontact = wp_remote_post('https://api.mailjet.com/v3/REST/contact', $MJF_data1_args); $MJF_responsecontactslist = wp_remote_post('https://api.mailjet.com/v3/REST/contactslist/' . $settings['MJF_listID'] . '/managecontact', $MJF_data2_args); @@ -73,6 +78,10 @@ public function run($record, $ajax_handler) { $MJF_responsecontactdata = wp_remote_post('https://api.mailjet.com/v3/REST/contactdata/' . $fields['email'], $MJF_contactdata3_args); } + if ($fields['custom']) + { + $MJF_responsecontactdata = wp_remote_post('https://api.mailjet.com/v3/REST/contactdata/' . $fields['email'], $MJF_contactdata4_args); + } } public function register_settings_section($widget) @@ -87,6 +96,8 @@ public function register_settings_section($widget) $widget->add_control('MJF_phone_field', ['label' => __('Mailjet Phone field', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Set your mailjet contact phone field.', 'text-domain') , ]); + $widget->add_control('MJF_custom_field', ['label' => __('Mailjet Custom field', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Set your own mailjet custom field.', 'text-domain') , ]); + $widget->end_controls_section(); } @@ -97,5 +108,6 @@ public function on_export($element) unset($element['MJF_firstname_field'],); unset($element['MJF_name_field'],); unset($element['MJF_phone_field'],); + unset($element['MJF_custom_field'],); } } \ No newline at end of file diff --git a/README.md b/README.md index 9d34e98..84d0ac7 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,8 @@ Add your API Key and API Secret on wp-config.php ```define( 'MAILJET_API', '' );``` -```define( 'MAILJET_SECRET', '' );``` \ No newline at end of file +```define( 'MAILJET_SECRET', '' );``` + +Select a elementor form, add an output action "Mailjet", type the list ID you want your subscribers to be part of, Mailjet do not enforce any field or custom merge tag by default. In order for the plugin to work, please set them according to your account value on the elementor output action "Mailjet" settings. + +Name your forms fields as : name firstname phone custom in order to assign them to the plugin. \ No newline at end of file diff --git a/readme.txt b/readme.txt index 5a0c860..bcad128 100644 --- a/readme.txt +++ b/readme.txt @@ -1,7 +1,7 @@ === MJ FORMS === Contributors: Jonathan DAHAN -Stable tag: 1.0.1 -Tested up to: 5.8 +Stable tag: 1.0.2 +Tested up to: 5.9.1 Requires at least: 5.8 This plugins add Mailjet output Action for elementor forms. @@ -15,4 +15,5 @@ Add your API Key and API Secret on wp-config.php define( 'MAILJET_API', '' ); define( 'MAILJET_SECRET', '' ); -Select a elementor form, add an output action "Mailjet", type the list ID you want your subscribers to be part of. \ No newline at end of file +Select a elementor form, add an output action "Mailjet", type the list ID you want your subscribers to be part of, Mailjet do not enforce any field or custom merge tag by default. In order for the plugin to work, please set them according to your account value on the elementor output action "Mailjet" settings. +Name your forms fields as : name firstname phone custom in order to assign them to the plugin. \ No newline at end of file