Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

User Field Login

No security coverage Under active development 34 sites

This module allows users to log in using values from any Drupal field, provided those values are unique. Administrators can configure which fields are enabled for login and customize the login form's username field.

INTRODUCTION

  • This module allows users to log in using field data values, administrators can
    customize the fields allowed to log in.
  • Special fields can use plug-ins or hooks to query the user UID to achieve
    login, for example: Phone number (field). You can also use any data to log in,
    you only need to query and output the user's UID.

REQUIREMENTS

  • Field values must be unique.
  • Field values cannot have special symbols or spaces.

INSTALLATION

Install the field login module as you would normally install a contributed
Drupal
module. Visit https://www.drupal.org/node/1897420 for further information.

CONFIGURATION

Go to "/admin/config/people/accounts/field-login" for the configuration screen,
available configuraitons:

- Select login field address: This option enables the user to login to the field
address
- Override login form: This option allows you to override the login form
username title/description.
- Login form username title: Override the username field title.
- Login form username description: Override the username field description.

HOOK FIELD LOGIN

Example: Phone number (field)

function hook_field_login(string $field_name, $inputValue): array {
  if ($field_name == 'field_telephone') {
    return \Drupal::entityQuery('user')
      ->accessCheck()
      ->condition('field_telephone.local_number', $inputValue)
      ->execute();
  }
  return [];
}

PLUGIN FIELD LOGIN

Example: Phone number (field)

Please place the file in your own module: src\Plugin\FieldLogin

use Drupal\field_login\FieldLoginPluginBase;

/**
 * Plugin implementation of the field_login.
 *
 * @FieldLogin(
 *   id = "phone",
 *   label = @Translation("Phone field"),
 *   description = @Translation("Phone field description."),
 *   field_name="field_phone",
 *   field_type="sms_phone_number"
 * )
 */
class PhoneField extends FieldLoginPluginBase {

  public function getAccountUid($inputValue): array {
    return \Drupal::entityQuery('user')
      ->accessCheck()
      ->condition('field_phone.local_number', $inputValue)
      ->execute();
  }

}
Drupal 11 · not 10

Ask your assistant about User Field Login

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

1 tracked project depends on this one

Activity

Tracked releases
16
Tracked since
Jun 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 3
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
2.0.2 Stable 8–10 Jun 15, 2023
2.0.1 Stable 8–10 Jun 15, 2023
2.0.0 Stable 8–10 Jun 5, 2023
2.x-dev Dev 8–10 Jun 5, 2023
1.1.x-dev Dev 8–10 Jun 3, 2023
1.1.0 Stable 8–9 Jun 3, 2023