I have a situation where I need to authenticate users with three values (as opposed to a single USERNAME value. Let’s call them VALUE1, VALUE2, VALUE3. They will not be asked for a specific PASSWORD.

I looked into modifying the login routine such that it requests three values, and authenticates the user based on those three values. But because WordPress needs a unique USERNAME field and one of the values entered in the login page will effectively need to be the USERNAME, this won’t work, simple because none of the three values are unique in their own right. What’s unique is the combination of all three values.

This lead to the idea that the USERNAME stored in WP could be a value derived from concatenating the three values I require (VALUE1, VALUE2, VALUE3). So the USERNAME will be VALUE1VALUE2VALUE3.

I would also use this concatenated value as the PASSWORD, because I don’t require the user to enter a separate password if they know the three values I am requesting.

QUESTION 1

My first question is whether or not the above rationale is accurate? Is it true that even if I add additional fields to the login routine, one of those fields will need to correspond to the USERNAME value, and that value will need to be unique?

QUESTION 2

If the above is correct, then my next question is how would I go about creating a login form that requests three fields (plus the password), and concatenates those fields into one value that is authenticated against the USERNAME?

For example

The custom login page will request the following:

VALUE1, VALUE2, VALUE3

It will then concatenate those into VALUE1VALUE2VALUE3 and pass that to the standard WP login routine as the USERNAME and PASSWORD values.


Obviously, I’d want to achieve all this without modifying core files. The site has a child theme, so it can all be done within there.

Read more here: Adding a login form that concatenates three fields into a username


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: