I use plugin mailjet-for-wordpress.
What I want
want user to input thier nom,prenom and email in front end like this :http://gyazo.com/b58675c671584f8edc6ab6d703370ba9
My problem
for field I just add like nom,prenom it does not show in my admin page the same as email field when user subcribe : http://gyazo.com/9b72fdc03d22732cf21ddac9f70b2c33
what i have tried
I have tried to create contact properties field in mailjet like nom,prenom. And I’m also try to modify widget “Subscript to our newsletter” I add more fields in the newsletter form. I have modify code as below :
file mailjet-widget.php
// WIDGET CODE GOES HERE
echo '
<form class="subscribe-form">
//add field nom
<input type="text" name="nom" placeholder="' . __('Nom', 'wp-mailjet') . '" class="username">
//add field prenom
<input type="text" name="prenom" placeholder="' . __('Prenom', 'wp-mailjet') . '" class="username">
//email it is original field in default newsletter mailjet form
<input id="email" name="email" value="" type="email" placeholder="' . __('your@email.com', 'wp-mailjet') . '" />
<input name="action" type="hidden" value="mailjet_subscribe_ajax_hook" />
<input name="list_id" type="hidden" value="' . $list_id . '" />
<input name="submit" type="submit" class="mailjet-subscribe" value="' . __($button_text) . '">
</form>
<div class="response">
</div>';
And also in this function mailjet_subscribe_from_widget()
public function mailjet_subscribe_from_widget()
{
// Get some variables - email, list_id, etc.
$email = $_POST['email'];
$list_id = $_POST['list_id'];
//field add
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
// Add the contact to the contact list
$result = $this->api->addContact(array(
'Email' => $email,
'Nom' => $nom,
'Prenom' => $prenom,
'ListID' => $list_id
));
// Check what is the response and display proper message
if(isset($result->Status)) {
if($result->Status == 'DUPLICATE'){
echo '<p class="error">';
echo sprintf(__("The contact %s is already subscribed", 'wp-mailjet'), $email);
echo '</p>';
die();
}
else if($result->Status == 'ERROR'){
echo '<p class="error">';
echo sprintf(__("Sorry %s we couldn't subscribe at this time", 'wp-mailjet'), $email);
echo '</p>';
die();
}
}
// Adding was successful
echo '<p class="success">';
echo sprintf(__("Thanks for subscribing with %s", 'wp-mailjet'), $email);
echo '</p>';
die();
}
I have tried to search and test like this for a few days but still can not get the result.I am new with the plugin mailjet-for-wordpress plugin,
Do anyone know help me to find the solution please,
Thanks in advanced,
We would like to suggest 2 additional API calls.
GET https://api.mailjet.com/v3/REST/contact/user@email.com
You should receive a response similar to
PUT https://api.mailjet.com/v3/REST/contactdata/5
The response will contain the same Data object with updated data.
To integrate those two API requests in WP plugin, you should add and create more PHP methods.
Example for the first API call:
In mailjet_subscribe_widget() get the contact id with
The ID here would be in $result-Data[0]>ID
For the second call, please use the example to integrate it.