I have this code:

function mymod_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
  $form['account']['#weight'] = 100;

Which is supposed to push the 'account' section of stuff underneath the rest of the form elements. But the weight seems to be fixed/the order is unchanged?

I've inspected the $form array at the point my code runs, and there are all the other fields, with their respective #weight values; and 100 is larger than any of those.

1 Answer 1


The weight you set here would be overridden by the weight values you set via Mange Fields.


You can get around this by changing the weight in pre_render.


function mymod_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
  $form['#pre_render'][] = 'mymod_form_alter_weight';

function mymod_form_alter_weight($elements) {
  $elements['account']['#weight'] = 100;

  return $elements;

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.