Getting Started. Come on unisender.com, your Account Settings activate the API and remember the key to it. Then go to My Lists (ie distribution) and learn id our newsletters. To do this, simply summing the cursor to the desired editing the list and see its number in the tooltip, it is also present in the reference editing. Remember these numbers.
Now go to our website to wordpress. Here we need the id of our forms, with which we will send information to unisender, as well as the names of the fields we need, which we will pass. In our case, everything is standard, we need to send the name and email (to subscribe because nothing more is needed), these fields we are called standard [your-name] and [your-email]. Write the data.
With the preparatory part is over, proceed to implementation. We will write a plugin that will get the information we need with the right to form Contact Form 7 and transfer it in the background through the API to unisender.com, automatically signing the user to the correct e-mail us.
In the folder wp-content/plugins create a file of our plug-in, call it whatever you like, for example unisender.php. And in this file insert here the following code (after editing it for themselves, according to the comments below):
<?php /* Plugin Name: Contact Form 7 API Unisender Plugin URI: https://webpatron.net Description: Automatic subscription to Unisender Author: Webpatron Ltd. Version: 1.0 Author URI: https://webpatron.net */ function wpcf7_get_unisender (&$WPCF7_ContactForm) { if ($WPCF7_ContactForm->posted_data['_wpcf7'] == "NOMER_FORMY_1"){ $firstname = $WPCF7_ContactForm->posted_data['your-name']; $email = $WPCF7_ContactForm->posted_data['your-email']; file_get_contents('http://api.unisender.com/en/api/subscribe?format=json&api_key=APIKEY&list_ids=NOMER_PODPISKI_1&fields[email]='.$email.'&fields[Name]='.$firstname.'&double_optin=0&overwrite=0'); } elseif ($WPCF7_ContactForm->posted_data['_wpcf7'] == "NOMER_FORMY_2") { $firstname = $WPCF7_ContactForm->posted_data['your-name']; $email = $WPCF7_ContactForm->posted_data['your-email']; file_get_contents('http://api.unisender.com/en/api/subscribe?format=json&api_key=APIKEY&list_ids=NOMER_PODPISKI_2&fields[email]='.$email.'&fields[Name]='.$firstname.'&double_optin=0&overwrite=0'); } } add_action("wpcf7_mail_sent", "wpcf7_get_unisender"); ?>
Change the following values:
- NOMER_FORMY_1 и NOMER_FORMY_2 — Instead, we enter our forms of id WordPress.
- NOMER_PODPISKI_1 и NOMER_PODPISKI_2 — this number accordingly our newsletters when unisender.com.
- APIKEY — this is our key to the API, which we got on unisender.
- Value 0 in double_optin says that the user has to send a request to confirm consent to the newsletter. If you put 1, then this agreement have no one to ask.
That's basically all. We go now to the admin panel Wordpress, and activate the newly created us Contact Form 7 plugin API Unisender.
Everything works, the task set is performed.
UPD 02.02.2015: Unfortunately, the newest version of Contact Form 7, the method of integration is not already running. You must either deal with the new version, or use the old one. If you will need to develop a new version - you can contact our support team and discuss the development of a new plug-in for a fee.