5

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

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. ;)

  • 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 Mar 8 '12 at 15:35
  • Not as far as I can tell, but I have written most of the code for you ;) – wiifm Mar 18 '12 at 3:18

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.