2

In my Drupal 7 site, I inserted values into the 'surname' and 'date of birth' fields of my database tables. I want to prevent new users whose username and date of birth do not match those on my database from being able to log into my site. How do I achieve this? Thank you in anticipation.

2

There is (AFAIK) no module that will do this for you.

But you will be able to add and process any additional criteria for logging in by using hook_user_login to insert your own business logic into the login process. In this hook, you may insert code to redirect those users that you do not want to login to a page that explains the situation. There is an example on how to redirect logins in the comment thread in the API documentation for hook_user_login on Drupal.org.

For sake of completeness, I also mention that it is also possible to stop users not meeting specific criteria from registering in the first place. To do this, you add an additional validation callback function for the registration form processing using hook_form_FORM_ID_alter. There is a question on Stack Overflow that explains how to do this in detail for Drupal 6.

  • Thank you. Am using drupal 7. I have 2 roles on my site, and need to validate only one of them against my previously inserted database values......hence my desire to do it after log in – seyi Apr 19 '13 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.