Title: &#8220;AND&#8221; Between fields
Last modified: March 6, 2024

---

# “AND” Between fields

 *  Resolved [jolive](https://wordpress.org/support/users/jolive/)
 * (@jolive)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/and-between-fields/)
 * I run a children’s sports team and I use contact form to help with registration
   for events. I want to prevent duplicates but I need to filter on 2 or 3 fields.
   Like “First Name” AND “Last Name” AND “Email address”. Some families have more
   than one child so just checking against last name or email address may prevent
   them from signing up a second kid. Any thoughts?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [NIA](https://wordpress.org/support/users/wpnia/)
 * (@wpnia)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/and-between-fields/#post-17480995)
 * Hello jolive,
 * This plugin does not treat this case.
 * So, to achive what you desire you need to edit source code of this plugin.
    - For that you need to go to your **WordPress **administrator page->**Plugins**-
      >**Plugin File Editor**
 *  - From the right side -> **Select plugin to edit** -> search for **Duplicate
      Killer**
 *  - From **Plugin files** search for_ ‘functions\_cf7.php’_ file under _‘includes’
      _folder
 *  - You need to replace the entire function _duplicateKiller\_cf7\_before\_send\
      _email_ from line **48 **to **127**.
      Replace with:
 *     ```wp-block-code
       function duplicateKiller_cf7_before_send_email($contact_form, &$abort, $object) {
           global $wpdb;
           $table_name = $wpdb->prefix.'dk_forms_duplicate';
       	$cf7_page = get_option("CF7_page");
           $submission = WPCF7_Submission::get_instance();
       	$form_name = $contact_form->title();
       	$form_cookie = isset($_COOKIE['dk_form_cookie'])? $form_cookie=$_COOKIE['dk_form_cookie']: $form_cookie='NULL';
           if($submission){
       		$abort = false;
       		$no_form = false;
       		$AND = array();
               $data = $submission->get_posted_data();
               $form_data = array();
               foreach ($data as $key => $d) {
                   $tmpD = $d;
       				if (!is_array($d)){
       					$bl   = array('\"',"\'",'/','\\','"',"'");
       					$wl   = array('&quot;',''','/', '\','&quot;',''');
                           $tmpD = str_replace($bl, $wl, $tmpD );
                       }
                       //$form_data[$key] = $tmpD;
       				foreach($cf7_page as $cf7_form => $cf7_tag){
       					if($form_name == $cf7_form){
       						$i = count($cf7_tag);
       						if(array_key_exists($key,$cf7_tag)){
       							$no_form = true;
       							if($result = duplicateKiller_check_duplicate("CF7",$form_name)){
       								foreach($result as $row){
       									$form_value = unserialize($row->form_value);
       									if(isset($form_value[$key]) AND duplicateKiller_check_values_with_lowercase_filter($form_value[$key],$tmpD)){
       										$AND[$key] = $form_value[$key];
       										//echo $j.' '.$form_value[$key].'</br>'; 
       										if(function_exists('cfdb7_before_send_mail')){
       											remove_action('wpcf7_before_send_mail', 'cfdb7_before_send_mail');
       										}
       										$cookies_setup = [
       											'plugin_name' => "cf7_cookie_option",
       											'get_option' => $cf7_page,
       											'cookie_stored' => $form_cookie,
       											'cookie_db_set' => $row->form_cookie
       										];
   
       									}else{
       										if(!empty($tmpD))
       										$form_data[$key] = $tmpD;
       									}
       								}
       							}else{
       								if(!empty($tmpD))
       								$form_data[$key] = $tmpD;
       							}
       						}
       					}
       				}
               }
   
       		//print_r($AND);
       		if($i==count($AND)){
       			if(dk_check_cookie($cookies_setup)){
       					$abort = true;
       					$object->set_response($cf7_page['cf7_error_message']);						
       			}
   
       		}
       		//echo $i.' '.$j;
       		//exit();
       		if(!$abort AND $no_form){
       			$form_value = serialize($form_data);
       			$wpdb->insert(
       			$table_name,
       			array(
       				'form_plugin' => "CF7",
       				'form_name' => $form_name,
       				'form_value'   => $form_value,
       				'form_cookie' => $form_cookie
       			) 
       		);
       		}
           }
       }
       ```
   
 * **NOTE**: This code is for Contact Form 7, it wasn’t tested with other form plugins!
   **
   Also, please test it rigorous before going live!**
 * Let me know if you have any question.
 * Thank you, 
   NIA
 *  Plugin Author [NIA](https://wordpress.org/support/users/wpnia/)
 * (@wpnia)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/and-between-fields/#post-17563468)
 * Let me know if you have any question.
 * Topic closed!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘“AND” Between fields’ is closed to new replies.

 * ![](https://ps.w.org/duplicate-killer/assets/icon-256x256.png?rev=3446305)
 * [Duplicate Killer – Prevent Duplicate Form Submissions](https://wordpress.org/plugins/duplicate-killer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/duplicate-killer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/duplicate-killer/)
 * [Active Topics](https://wordpress.org/support/plugin/duplicate-killer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/duplicate-killer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/duplicate-killer/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [NIA](https://wordpress.org/support/users/wpnia/)
 * Last activity: [2 years, 1 month ago](https://wordpress.org/support/topic/and-between-fields/#post-17563468)
 * Status: resolved