Subscribe contacts with your Maileon account as newsletter recipients.
This plugin helps you to set up forms for subscribing contacts with your mailing lists in Maileon. It is fully configurable and provides customizable templates for simple forms, a sidebar widget, and the possibility to build more complex forms e.g. with Contact Forms 7. Since version 2.6.0 it is possible to add AddressCheck for your form to prevent misspelled e-mail addresses.
Make sure cURL, SPL and SimpleXML for PHP are installed and enabled and that you are using PHP 5.6.x or higher.
You can add a standard form using the shortcode [maileon-contact].
To configure the behavior of the form, you can set the attributes from the REST-API documentation for each form. An example for a common shorttag: [maileon-contact doi="true" doiplus="true" sync_mode=1 ]
For more information about the shorttags, please refer to our shorttag documentation
Please note that by default already existing contacts are not updated to avoid customers overriding information. If you think that updates should be allowed, please pass parameter sync_mode=1.
Example: [maileon-contact sync_mode=1]
Using multiple forms on the same page can be achieved by using a different template for each form, or by specifying the name
shortcode attribute for each.
The plugin comes with a set of predefined forms for newsletter subscription and allows adding own custom forms. In addition, there is the possibiligy to add forms for profile updates, e.g. letting a contact add or edit details.
For handling forms, please refer to our form documentation
The sidebar widget can be added and customized like any other widget. It provides a single registration form. The title and submit button text can be changed in the widget settings and it uses the confirmation messages from the general plugin settings.
For more details how to use the sidebar widget, please refer to our sidebar documentation
The form can also be connected with other form plugins, here an example for Contact Forms 7.
The basic approach is to add the following hook to your WordPress by using a plugin like Code Snippets (https://de.wordpress.org/plugins/code-snippets/)
// ------------------------------ Start CF7 Hook ------------------------------ // Prevent CF7 from sending mails add_action( 'wpcf7_before_send_mail', 'xq_wpcf7_before_send_mail' ); function xq_wpcf7_before_send_mail( $wpcf7_data ) { // Since version 4.0 the author changed $skip_mail to be private, use hook instead //$wpcf7_data->skip_mail = true; add_filter('wpcf7_skip_mail','xq_wpcf7_skip_mail'); $submission = WPCF7_Submission::get_instance(); $formData= $submission->get_posted_data(); // If only a form with a certain ID should be submitted, provide the id here // This can be extended to use an array of IDs or even check if a hidden field is available in the posted data... // In recent versions CF7 changed its ID to be the hash. If you want to continue using the ID (backwards compatible), // and add NEW forms by ID please do not use what is displayed as ID in the shorttag but when editing the CF7 form, // use parameter post_id in the url, // e.g. 11 in this example: ...?page=wpcf7&post=11&action=edit // In this case use: if (in_array($wpcf7_data->id(), array(11))) { // However, it is easier to use the CF7 hashes, that are now shown as alphanumerical IDs // e.g. d7e6ad0 in this example: [contact-form-7 id="d7e6ad0" title="Testform1"] // if (in_array($wpcf7_data->hash(), array("d7e6ad0"))) { $result = XQ_Maileon::register_contact($formData); // If there is an error set a message and add the error handler if (!$result['response']->isSuccess()) { global $message; $message = "Es ist ein Fehler aufgetreten: " . $result['response']->getBodyData(); add_filter( 'wpcf7_ajax_json_echo', 'xq_wpcf7_ajax_json_echo', 10, 2 ); } //} return $wpcf7_data; } // Method to update the status message function xq_wpcf7_ajax_json_echo($response, $result) { global $message; $response['mailSent'] = false; $response['status'] = 'mail_failed'; $response['message'] = $message; return $response; } // New method to skip mails from CF7 itself function xq_wpcf7_skip_mail($f){ $submission = WPCF7_Submission::get_instance(); return true; } // ------------------------------ End CF7 Hook------------------------------
This piece of code catches the submission of the form and checks if the ID of the form matches one of the provided elements, here 16 or 31. this check has been added to prevent all contact forms to submit data to Maileon, you can of course also remove this condition or check if a certain (hidden) post field is available. If the condition is fulfilled it registers the contact with Maileon. It also displays an error message in case of errors.
You can also pass configuration parameters in the form. The following are valid parameters and documented at: https://maileon.com/support/create-contact/
Elementor comes with a bunch of useful methods to submit data to external services.
Unfortunatelly you can neither define the data name of an element (you can set label, placeholder and even the ID but not the name) nor use placeholders for the GET parameters in the URL. As Elementor uses the language dependent Label as the “name” for data submission, it is not possible to use the webhook module directly. Instead, you must register a hook and process the data using our plugin.
The basic approach is to add the following hook to your WordPress by using a plugin like Code Snippets (https://de.wordpress.org/plugins/code-snippets/)
// ------------------------------ Start Elementor Hook ------------------------------ class Maileon_Elementor_Form_Hook { function register_maileon(){ //Add our additional webhook right here add_action( 'elementor_pro/forms/new_record', array( $this, 'maileon_elementor_form_callback' ), 10, 2 ); } function maileon_elementor_form_callback( $record, $ajax_handler ) { $form_data = $record->get_formatted_data(); // As you cannot specify the 'name' of form elements in elementor (you can specify the label, placeholders and the element id) // Elementor submits the form with the language dependent form label! // Here, you need to translate the form elements to the Maileon standard nomenclature. Also add configuration parameters here, if required. // Hint: If you want to use Maileon only for a single form, best give the form a unique name (in Elementor). Here we have set "Maileon Form" as name... //if ($record->get_form_settings( 'form_name' ) == "Maileon Form") { $new_data = array( 'email' => isset( $form_data['E-Mail'] ) ? $form_data['E-Mail'] : '', 'standard_LASTNAME' => isset( $form_data['Name'] ) ? $form_data['Name'] : '', 'standard_FIRSTNAME' => isset( $form_data['Vorname'] ) ? $form_data['Vorname'] : '', 'sync_mode' => 1, 'doiplus' => true ); $result = XQ_Maileon::register_contact($new_data); // If there is an error set a message and add the error handler if (!$result['response']->isSuccess()) { $message = "Es ist ein Fehler aufgetreten. Status-Code: " . $result['response']->getStatusCode(); //$ajax_handler->add_error( $field['id'], $message ); $ajax_handler->add_error_message( $message ); $ajax_handler->is_success = false; } //} } } $maileonHook = new Maileon_Elementor_Form_Hook(); $maileonHook->register_maileon(); // ------------------------------ End Elementor Hook ------------------------------
As commented in the code, you can use the plugin also for single forms, only by using e.g. the name of the form and uncomment the if clause.
You can help users preventing entering misspelled e-mail addresses by enabling AddressCheck in the plugin settings. ADC will check the mailbox of the e-mail address entered in your form in order to decide if it really exists or not. To enable AddressCheck, just provide your API user and API key and check “Use ADC”. You can also select an ADC check delay in seconds to prevent the plugin from checking the given address too often and an ID of the e-mail form field. The plugin will display ADC results by setting classes ‘adc_status_icon_valid’, ‘adc_status_icon_warn’, or ‘adc_status_icon_invalid’ to the e-mail form field and making an element with ID ‘adc_error_message’ visible or invisible, depending if there is a problem or not. An example form with ADC can be found in template=’maileon-contact-form-adc-sample.php’
The plugin supports Polylang (https://wordpress.org/support/plugin/polylang/), so you can set up different texts e.g. for successful registrations. Just install and set up Polylang and go to “Languages” -> “String Translations” and filter for “xqueue-maileon” to get a list of translatable content.
This plugin can redirect to pages but this is only possible if no headers were already sent to the web browser, i.e. if no (other) plugin has already sent output. To avoid this, this script buffers output for POST requests. If you still find this error message, please contact us.
This plugin uses serverside sessions to save values for the (old) captcha method. If caching is enabled for the newsletter registration forms it can happen that outdated captcha data is shown. Further, on POST requests, this plugin enables buffering as some other plugins sometimes send headers early which makes it impossible to forward to proper landingpages later on.
We do not show internal error information to frontend users. When you enable the WP debug mode (define('WP_DEBUG', true) and define('WP_DEBUG_LOG', true)) the plugin writes errors and warnings to the WP debug log, which you can usually find under /wp-content/debug.log.
Check your logs, most probably you do not have cURL for PHP installed. You should also see a warning in your administration panel.
Check your logs, most probably trigger Maileon to send a DOI request but you have not specified a default DOI Mailing under "Settings -> Double-Opt-In". Please do so and retry.
If you get a warning like "Invalid argument supplied for foreach() path\xqueue-maileon\class\class-xq-maileon.php on line 306" it might be an issue with special chars generated by the webserver when displaying the manual. We noticed that some examples are displayed using different types of colons for ' or ". Please make sure to use only those two characters to mark strings etc. in your form descriptor, e.g. instead use [maileon-contact standard="{'LOCALE':'de_DE'}" doimailing="FF3OfzjS"] instead of [maileon-contact standard="{'LOCALE':'de_DE'}" doimailing="FF3OfzjS"]
Sometimes the plugin page for WordPress translates some signs like regular ” or ‘ into special characters for better display. You need to replace them by the proper signs " and '.
The captcha implementation that relies on calculating simple math can cause this problem. If you cache the newsletter registration page, it might be possible, that the numbers are not updated in the form. Please make sure to disable caching for the registration page. Also it relies on sessions, so if sessions are disabled or broken, the captcha cannot work. In this case maybe think of using Google reCaptcha.
The current version is aligned with German law and thus, supports working with DOI and DOI+. In the short tags of registration forms, you can set doi to false and select a different permission to be set without DOI mail but for profile update pages, there is currently no possibility to change between different permissions than DOI and DOI+ (add/remove single user tracking).
Information: if you update, please make sure your form still works as expected as the templating system has changed.
from default form template