I would like to add the domain name of my company in a simple element right after the username login text input element. Something like this:

enter image description here

I already tried the instructions defined in https://drupal.org/node/350634 and this only affects the text field label or anything around the login form, but not the input fields themselves (unless I'm misunderstanding the directions). This method doesn't seem to affect how I can add an html element after the username text field but before the password text field.

I'm not certain how I should attempt this? Any direction would be wonderful.

BTW - I tried LoginToboggan to simply allow my users to use either their username or their email address, but that solution only partially works. We have LDAP integration, so for the first time the user attempts to log into our Drupal site they must use just their username (without the @companydomain.com) to allow the LDAP authentication to go through. I did not see a way to configure LoginToboggan to force the username through to the LDAP authentication.


2 Answers 2


You need to add suffix element to username field in login form. You can do it using hook_form_alter(&$form, &$form_state, $form_id)

Implement above hook in your custom module

function YOURMODULENAME_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    $form['name']['#suffix'] = '@mycompany.com';
  • Since I don't have a custom module, can I add the above function in my template.php file for my custom theme? Or should I build a custom module? Which is the better route?
    – Kaboukie
    Feb 25, 2014 at 22:04
  • hook_form_alter() is one of the hooks that's invoked for both themes and modules so putting it in your template.php file is fine. You can replace YOURMODULENAME with YOURTHEMENAME. You can build a custom module too. For more information drupal.org/developing/modules/7
    – Anil Sagar
    Feb 26, 2014 at 2:09

While Anil Sagar's answer is perfectly correct, sometimes you'll want to use '#field_suffix' instead of '#suffix' (when you add a title as well).

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.