5

Is there a way to force the users to use OpenID (e.g. Google, Facebook, Twitter) and not use Drupal's internal authentication?

1 Answer 1

5

I simple solution would be to alter the login form to remove the username and password fields.

Here is some sample code to get you started:

/**
 * Alter the login form page
 */
function MYMODULE_form_user_login_alter(&$form, &$form_state, $form_id) {
  _MYMODULE_alter_login_form($form);
}

/**
 * Alter the login form block
 */
function MYMODULE_form_user_login_block_alter(&$form, &$form_state, $form_id) {
  _MYMODULE_alter_login_form($form);
}

/**
 * Function to change a bunch of things in the user_login form (both the block
 * and login screen).
 */
function _MYMODULE_alter_login_form(&$form) {
  unset($form['name']);
  unset($form['pass']);
}

Unfortunately I don't know of any contrib modules that will do this for you; the good news is that I have wrote 95% of the module for you. ;)

3
  • I don't know that much about Drupal nor PHP, so I don't really want to alter login form, is there a way to do it using something out of the box?
    – alexus
    Commented Mar 8, 2012 at 15:35
  • Not as far as I can tell, but I have written most of the code for you ;)
    – wiifm
    Commented Mar 18, 2012 at 3:18
  • See drupal.stackexchange.com/a/41753/39617 Commented Oct 2, 2015 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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