Plugin / Bin Opt-In

Berg Informatik

Description

Description

Provides features and functions to create an opt-in or double-opt in with contact form 7 (cf7) and other form plugins.

Save contacts

To store your contacts, please install the additional plugin called bin contact. This plugin assists you installing all the necessary dependencies.

Opt-In Function

BinOptIn::optIn($postdata, [
    'opt_in_admin_message' => false,
    'double_opt_in' => false,
    'admin_unlock' => false,
    'unlock_message' => false
]);
  • opt_in_admin_message
    (bool) Notify the site owner of any new contact, regardless of whether or not he has confirmed his e-mail address. Default false.

  • double_opt_in
    (bool) The contact must confirm the e-mail address by clicking on a confirmation link. Default false.

  • admin_unlock
    (bool) The site owner has to confirm every new contact by clicking on a confirmation link. This is useful if you want to show a list of contacts (like a committee or a list of supporters). Default false.

  • unlock_message
    (bool) This option allows you to specify whether the contact should receive a notification once the site owner has confirmed the committee subscription. Default false.

Accepted postdata

  • salutation
    (int) Default empty.

    • 0 (Mister)
    • 1 (Miss)
    • 2 (Other)
  • polite_form
    (int) Default empty.

    • 0 (Personally)
    • 1 (Formally)
  • language_of_correspondence
    (int) Check this functions to see a list of all available languages: BinContact::formLanguage() and BinContact::formLanguageValue()

  • name_suffix
    (string) Default empty.

  • first_name
    (string) Default empty.

  • last_name
    (string) Default empty.

  • designation
    (string) Default empty.

  • mobile
    (string) Default empty.

  • phone_private
    (string) Default empty.

  • phone_work
    (string) Default empty.

  • street_and_number
    (string) Default empty.

  • zip
    (string) Default empty.

  • city
    (string) Default empty.

  • country
    (string) Default empty.

  • website
    (string) Default empty.

  • facebook
    (string) Default empty.

  • twitter
    (string) Default empty.

  • instagram
    (string) Default empty.

  • flickr
    (string) Default empty.

  • linkedin
    (string) Default empty.

  • xing
    (string) Default empty.

  • youtube
    (string) Default empty.

  • socialmedia_other1
    (string) Default empty.

  • socialmedia_other2
    (string) Default empty.

  • socialmedia_other3
    (string) Default empty.

  • terms_and_conditions_accepted
    (string) Default empty.

    • empty (Not filled)
    • no (No)
    • yes (Yes)
  • privacy_policy_accepted
    (string) Default empty.

    • empty (Not filled)
    • no (No)
    • yes (Yes)

Integrate with Contact Form 7

Bin Opt-In works best with contact form seven. To integrate it into your contact forms, you need to add custom code like this to your theme functions.php.

add_action('wpcf7_before_send_mail', 'bin_opt_in_contact');
function bin_opt_in_contact($cf7)
{
    // Get current form id
    $formId = $cf7->id;

    // Array of form ids
    $forms = [159, 454];

    // Only apply to certain forms
    if(in_array($formId, $forms))
    {
        // Dont do anything if class is missing
        if(class_exists('BinOptIn'))
        {
            // At least, the email must be present
            if(is_email($_POST['email']))
            {
                // map salutation
                $salutationMap = [ 
                    'Frau' => 0,
                    'Madame' => 0,
                    'Mrs' => 0,
                    'Herr' => 1,
                    'Monsieur' => 1,
                    'Mr' => 1,
                    '*' => 2
                ];

                // assign form data with corresponding meta fields
                $postdata = [];
                $postdata['email'] = sanitize_email($_POST['email']);
                $postdata['first_name'] = sanitize_text_field($_POST['first_name']);
                $postdata['last_name'] = sanitize_text_field($_POST['last_name']);
                $postdata['salutation'] = $salutationMap[$_POST['salutation']];
                $postdata['terms_and_conditions_accepted'] = isset($_POST['terms_and_conditions_accepted']) ? 'yes' : '';

                // save contact
                BinOptIn::optIn($postdata, [
                    'opt_in_admin_message' => false,
                    'double_opt_in' => false,
                    'admin_unlock' => false,
                    'unlock_message' => false
                ]);
            }
        }
    }
}

Integrate with Contact Form 7 Multi-Step Pro

Save form data at every step by using the filter wpcf7_validate.

add_filter('wpcf7_validate', 'save_contact_step', 10, 2);
function save_contact_step($result, $tags)
{
    // Get current form id
    $formId = $_POST['_wpcf7'];

    // Array of form ids
    $forms = [159, 454];

    // Only apply to certain forms
    if(in_array($formId, $forms))
    {
        // Dont do anything if class is missing
        if(class_exists('BinOptIn'))
        {
            // save contact info here
            // BinOptIn::optIn()
        }
    }

    return $result;
}

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.