• Resolved sreed27

    (@sreed27)


    First of all- great plug-in! This is really a great tool! I was wondering if there was a way to customize this plug-in to use a field other than email to check for duplicate records. Many of my records do not have an email address, but I’d like to be able to reimport my database from CSV and overwrite/update records annually in order to update a yearly recurring date for each record. I’d like to be able to have my own ID field associated with each record that could be the primary key for identifying duplicates. Is this possible?

    http://wordpress.org/extend/plugins/participants-database/

Viewing 2 replies - 1 through 2 (of 2 total)
  • This worked for me, file participants-database.php. On lines 1010 to 1025 you will find this code. Change each instance of “email” to be the column name you want to use to identify duplicates. In my case the column name was soldier_number. Where you now see soldier_number is where you have to make changes, remember column name, NOT column title must be used. If I haven’t changed something such as “unique_email” or “$email” then don’t change it.

    $options = get_option( self::$participants_db_options );
    
    		// check for an existing record with same email so we can at least avoid
    		// inserting a duplicate email address into the database
    		if ( $options['unique_email'] && isset( $post['soldier_number'] ) && ! empty( $post['soldier_number'] ) && self::email_exists( $post['soldier_number'] ) ) {
    
          // record with same email exists...get the id and update the existing record
          $participant_id = self::_get_participant_id_by_term( 'soldier_number', $post['soldier_number'] );
    
    			// if there is more than one record with a particular email, return the first one
    			if ( is_array( $participant_id ) ) $participant_id = current( $participant_id );
    
    			//unset( $post['private_id'] );
          $action = 'update';
    
        }

    Then on lines 1257 to 1267 you will find this code:

    /**
       * tests for the presence of an email address in the records
       *
       * @param string $email the email address to search for
       * @return boolean true if email is found
       */
      public function email_exists( $email ) {
    
        return self::_id_exists( $email, 'soldier_number' );
    
      }

    Change the “email” to be your column name here as well.

    Then do some testing. Hope this works for you.

    Wayne

    Thread Starter sreed27

    (@sreed27)

    Yes, this worked well, and I was able to import updated data into existing records based on the private_id field (instead of email address which I am not using in my participants list) set as the field to check when evaluating possible duplicates. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Participants Database] Identifying duplicates by field other than email’ is closed to new replies.