When importing a CSV, it is possible to configure it to match and update existing records. The same process can also be used when a new record is submitted via the signup form. Normally, this is done by matching a single identifying field such as an ID or email address.
In some cases, it’s desirable to perform the match based on multiple fields, such as the first and last name. In this tutorial, I will show you a plugin that lets you set up such a multiple-field matching check.
Setting Up the Match
This plugin works by checking a list of fields that must match an existing record in order for the incoming data to update the matched record in the database.
At the top of the plugin below, you’ll find an array, $match_field_list, where the list of fields you want to check is placed. When a record comes in, either from a signup form or from a CSV file, the contents of that new data is used to search for a record in the database that has the same values in all the fields in that list. If a match is found, the found record is updated with the values in the incoming data. If no match is found, a new record is created with the incoming data.
To use this plugin, click on the link below the code window, download the .zip file, then upload it using the “Add New” item in the admin Plugins menu. To set up the field you want to use for your application, edit the plugin using the plugin file editor. If the plugin file editor is not available, you’ll need to unzip it, edit it on your local machine, zip it, then upload and install.