Posted on by

Recovering a Private Link Using Multiple Fields

Participants Database uses a “private link” to allow participants to access their record for editing. If that link is lost, it’s possible for them to recover it by using a private link recovery form where they enter their email (typically) and have the link sent to them in an email.

In some setups, there isn’t a convenient single-field identifier (usually, the email address) to use in getting a private link sent to a user that has lost theirs. For example, if multiple records have the same email. In cases like this, what is needed is a link recovery form that uses more than one field to identify which record will be accessed by the private link.

For our example here, let’s say we need to get the email and the first name.

First thing to do is set up the link recovery form on its own page so that a custom shortcode can be used. In our example, the shortcode should be:

Request your Private Link

We’re telling the shortcode which fields we want shown. By the way, this is also how you can include a CAPTCHA in your link recovery form if you want.

In the plugin settings, under the “Resend Link” tab, set the “Lost Private Link Page” dropdown to point to the page with that shortcode. When the “lost private link” link is clicked, they will go to that page.

Once you get it working and try it out a few times, you may notice that the error messaging (if the form isn’t filled out right) doesn’t know about the extra fields we’re adding, so I suggest you change the “Retrieve Private Link Error Message” to something generic like: “A matching record cannot be found.”

The Custom Plugin

Now, to actually validate the submission, we need to use a plugin that will take the submitted values and try to find a match. Here is the code for that, it is almost ready to go, you just need to make sure that the fields you are trying to match are named in the $match_fields array on line 30.

As always, this plugin gist is easily downloaded and installed…check this article for the “how to’s” on that:

How to Install a WordPress Plugin from a Gist

Leave a Reply

Your email address will not be published. Required fields are marked *

Would you like to be notified of followup comments via e-mail? You can also subscribe without commenting.

Leave a Reply

Your email address will not be published. Required fields are marked *

Would you like to be notified of followup comments via e-mail? You can also subscribe without commenting.