I am just pulling my hair out for the last two days trying to figure this out but as a new user of Drupal I cannot find the option where to change it. I have installed Mailchimp module in my drupal website and I want to display the newsletter option in the user registration page. It display fine but not in the right position. For some reason the block appears between the firstname and lastname field. I want to place this under email address field above the captcha. Can anyone please help me. I have tried to many things and cleared the cache but no luck.
1 Answer
Ok, you'll need to do this with a custom module and use hook_form_alter and set the weight of the mailchimp list properly.
function MODULE_form_alter(&$form, &$form_state, $form_id)
{
if ($form_id == "user_register_form")
{
//print_r($form);
//first name field - use proper name
$form["first_name"]["#weight"] = 1;
//last name field - use proper name
$form["last_name"]["#weight"] = 2;
//email field - use proper name
$form["email"]["#weight"] = 3;
$form["mailchimp_lists"]["#weight"] = 4;
}
}
You should use print_r($form);
or drupal_set_message(print_r($form,true));
to inspect the structure of your $form
array and get out the proper names of your fields to use in the hook.
-
Hi Scott, Thanks for your reply. Is there any other way to do this from admin section instead of creating custom module? Cheers, tajuddin– TajuddinOct 8, 2013 at 1:43
-