Hi everyone,

I picked up on Drupal 7 a few weeks ago and I've begun making my custom theme for my website. However, right now I am stuck on how to customize my authentication blocks for users to login and register.

So far, after scouring the web, I haven't come across a definitive guide to doing this. So after opening up the user.module file to inspect some code, I came across this,

function user_login($form, &$form_state) {
  global $user;

  // If we are already logged on, go to the user page instead.
  if ($user->uid) {
    drupal_goto('user/' . $user->uid);
  }

  // Display login form:
  $form['name'] = array('#type' => 'textfield',
    '#title' => t('Username'),
    '#size' => 60,
    '#maxlength' => USERNAME_MAX_LENGTH,
    '#required' => TRUE,
  );

  $form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal')));
  $form['pass'] = array('#type' => 'password',
    '#title' => t('Password'),
    '#description' => t('Enter the password that accompanies your username.'),
    '#required' => TRUE,
  );
  $form['#validate'] = user_login_default_validators();
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Log in'));

  return $form;
}

Truthfully, I would just like to remove/edit the default descriptions (i.e. '#description' => t('Enter the password that accompanies your username.'),) part of the login page. I would also like to know how I can stylize the form itself and all its components (i.e. the buttons) with CSS.

It would be really great if someone could explain to me how that works. Please and thank you!

Comments

nevets’s picture

You can implement hook_form_alter() to alter any form.

wOOge’s picture

In Drupal 7 ( D7 ) try adding this to your template.php — don't forget to CLEAR ALL CACHES after any changes to this file:



function YOURTHEMENAME_form_alter(&$form, &$form_state, $form_id) {

	if ($form_id == "user_login_block") {
		$form['links'] = Null; // Remove Request New Password and other links from Block form
		//$form['links']['#markup'] = t('Not Registerd?') . ' <a href="/user/register">' . t('Create Account') . '</a>'; // Remove Request New Password from Block form
		//$form['links']['#markup'] = ' <a href="/user/register">' . t('Create Account') . '</a>'; // Remove Request New Password from Block form
		$form['name']['#title'] = t("eMail"); // Change text on form
	}


--
wOOge | adrianjean.ca