Skip to content

Commit

Permalink
Merge pull request #1 from jonathandhn/dev
Browse files Browse the repository at this point in the history
Enchance description, increment to release 1.0.2, Add a fourth field …
  • Loading branch information
jonathandhn authored Mar 22, 2022
2 parents ad9dbb7 + 4737561 commit 776e17d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
14 changes: 13 additions & 1 deletion ActionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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)
Expand All @@ -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();

}
Expand All @@ -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'],);
}
}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ Add your API Key and API Secret on wp-config.php

```define( 'MAILJET_API', '' );```

```define( 'MAILJET_SECRET', '' );```
```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.
7 changes: 4 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
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.

0 comments on commit 776e17d

Please sign in to comment.