Plugin Directory

Changeset 2089733


Ignore:
Timestamp:
05/17/2019 09:13:05 AM (7 years ago)
Author:
ehsantikweb
Message:

Added the ability to add mailpoet custom field in contact form 7, tagging 1.3.9

Location:
add-on-contact-form-7-mailpoet
Files:
4 edited
11 copied

Legend:

Unmodified
Added
Removed
  • add-on-contact-form-7-mailpoet/trunk/add-on-contact-form-7-mailpoet.php

    r2086501 r2089733  
    33 * Plugin Name:       Add-on Contact Form 7 - Mailpoet 3
    44 * Description:       Add a MailPoet 3 signup field to your Contact Form 7 forms.
    5  * Version:           1.3.9
     5 * Version:           1.3.10
    66 * Author:            Tikweb
    77 * Author URI:        http://www.tikweb.dk/
     
    153153 */
    154154require_once MCFI_ROOT_PATH . 'includes/class-mailpoet-cf7-unsubscribe.php';
     155
     156/**
     157 * Mailpoet custom field
     158 */
     159require_once MCFI_ROOT_PATH . 'includes/class-mailpoet-cf7-custom-field.php';
     160
     161
  • add-on-contact-form-7-mailpoet/trunk/changelog.txt

    r2086501 r2089733  
    11== Changelog ==
     2
     3= 1.3.10 – 2019-05-17 =
     4* Added the ability to add mailpoet custom field in contact form 7
    25
    36= 1.3.9 – 2019-05-07 =
  • add-on-contact-form-7-mailpoet/trunk/includes/class-mailpoet-cf7-submit-form.php

    r2086501 r2089733  
    1717use MailPoet\Models\Subscriber;
    1818use MailPoet\Subscribers\ConfirmationEmailMailer;
    19 
     19use MailPoet\Models\CustomField;    #get all custom field info without value
    2020
    2121if ( ! class_exists( 'MailPoet_CF7_Submit_Form' ) ) {
     
    2929            return $_this_class;
    3030        }
    31 
    3231
    3332        /**
     
    7978         */
    8079        public function add_email_list( $form_data, $form_tags ) {
     80
    8181            // Get field name to get form value
    8282            $field_names = $this->get_email_and_list_name( $form_tags );
     
    110110                } elseif ( isset( $form_data['your-firstname'] ) ) {
    111111                    $firstname = trim( $form_data['your-firstname'] );
    112                 }elseif ( isset( $form_data['firstname'] ) ) {
     112                } elseif ( isset( $form_data['firstname'] ) ) {
    113113                    $firstname = trim( $form_data['firstname'] );
    114                 }
    115 
    116                 else {
     114                } else {
    117115                    $firstname = '';
    118116                }
     
    126124                } elseif ( isset( $form_data['lastname'] ) ) {
    127125                    $lastname = trim( $form_data['lastname'] );
    128                 }
    129 
    130                 else {
     126                } else {
    131127                    $lastname = '';
    132128                }
    133 
    134 
    135129
    136130                //Save all list
     
    171165                }
    172166
     167
     168                #Get custom fields and fields type
     169                $fields       = CustomField::findMany();
     170                $results      = array();
     171                $results_type = array();
     172                foreach ( $fields as $field ) {
     173                    $results[ 'cf_' . $field->id ]      = $field->name;
     174                    $results_type[ 'cf_' . $field->id ] = $field->type;
     175                }
     176
     177
    173178                if ( ! empty( $list_ids ) && is_array( $list_ids ) ) {
    174179                    $subscribe_data = array(
     
    177182                        'first_name' => $firstname,
    178183                        'last_name'  => $lastname,
    179                         'status'     => 'unconfirmed'
     184                        'status'     => 'unconfirmed',
    180185                    );
     186
     187                    #If custom field presents, append the fields value to subscribe data
     188                    if ( ! empty( $results ) ) {
     189                        foreach ( $results as $key => $value ) {
     190                            foreach ( $results_type as $key_type => $value_type ) {
     191                                if ( $value_type == 'radio' ) {
     192                                    $subscribe_data[ $key_type ] = $form_data[ $key_type ][0];
     193                                } elseif ( $value_type == 'checkbox' && ! ( empty( $form_data[ $key_type ][0] ) ) ) {
     194                                    $subscribe_data[ $key_type ] = 1;
     195                                } elseif ( $value_type == 'checkbox' && ( empty( $form_data[ $key_type ][0] ) ) ) {
     196                                    $subscribe_data[ $key_type ] = 0;
     197                                } else {
     198                                    $subscribe_data[ $key ] = $form_data[ $key ];
     199                                }
     200                            }
     201                        }
     202                    }
    181203
    182204                    //Save subcriber data
  • add-on-contact-form-7-mailpoet/trunk/readme.txt

    r2086501 r2089733  
    44Donate link: http://www.tikweb.dk/donate/
    55Requires at least: 4.6
    6 Tested up to: 5.1.1
     6Tested up to: 5.2
    77Requires PHP: 5.2
    8 Stable tag: 1.3.9
     8Stable tag: 1.3.10
    99
    1010Add a MailPoet 3 signup field to your Contact Form 7 forms.
Note: See TracChangeset for help on using the changeset viewer.