What you did is absolutely correct, and probably did work. You can change the weight of the fields with the method described above.
The username field is not always rendered. The reason is that a persmission is required: change own username
. If that perm is not set, you wont be allowed to alter you username and the field wont be shown.
Info on debugging.
Your info alone is not quite enough to debug. From what you describe, you are doing the right thing, but other modules could be making things a bit tricky for you. The devel module is quite good when it comes to debugging, ti defines two functions I use a lot when debugging:
dpm()
pretty prints the variable to the message area using krumo.
dd()
Prints / saves a variable to a log file. Useful when you can't view messages on the screen.
I would suggest that you look at the $form
variable before and after you alter it.
Things that could make it go wrong:
- Did you remember to pass the
$form
variable by reference using the &
notation?
- Is another module altering your form after you?
- Are you checking for the correct form id, so you alter the correct form?
These are some pointers, before you bring more info, all I can do is guess to what your problem exactly can be. I did something like this a few days ago so I know what you describe shouldn't be a problem.