Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The current login form looks like this
<div>
<div class="form-item form-type-textfield form-item-name compact-form-wrapper">_</div>
<div class="form-item form-type-password form-item-pass compact-form-wrapper">_</div>
<div class="item-list">_</div>
<input type="hidden" name="form_build_id" value"...">
<input type="hidden" name="form_id" value"...">
<div class="form-actions form-wrapper" id="edit-actions">_</div>
</div>
but I would like to swap some html elements to this
<div>
<div class="form-item form-type-textfield form-item-name compact-form-wrapper">_</div>
<div class="form-item form-type-password form-item-pass compact-form-wrapper">_</div>
<div class="form-actions form-wrapper" id="edit-actions">_</div>
<div class="item-list">_</div>
<input type="hidden" name="form_build_id" value"...">
<input type="hidden" name="form_id" value"...">
</div>
I have no php skills but I've been told to insert this function:
/**
* Implements hook_form_FORM_ID_alter().
*/
function yourmodule_form_user_login_block_alter(&$form, &$form_state) {
$form['name']['#weight'] = -4;
$form['pass']['#weight'] = -3;
$form['actions']['#weight'] = -2;
$form['links']['#weight'] = -1;
}
Is this the appropiate function?
Thank you