Hi There,

I am getting very close to wrapping up my first Drupal project, but there are a couple things holding me up that I was hoping someone could help me with. I've been able to create a module that will give me the user registration form in a block, however, I would like to include only a couple of fields from some add-on modules in the form rather than the entire add-on module form.

For example, I would like to include the zip code from the Location (User Locations) module on the registration form, but nothing else from Location, and I would also like to remove the fieldsets and wrappers and so on. I can't seem to find a good way to this. I can add a zip code field to the form, but then I'm not sure to handle it when it is submitted, and I can include the zip code field from Location, but then it includes the entire location field.

I would like to do the same with a couple fields from Profile 2.

Thanks in advance!
-Walker

Comments

chandan chaudhary’s picture

you want something like fast registration form in drupal?

Need Drupal help?
Reach me

Acquia Certified Developer

Backend Frontend and DevOps.

skywalkerwilliamson’s picture

Hi Chandan,

I took a look at the Fast Registraion module, and it's *close* to what I'm looking for. However, I see that development stopped on that project at Drupal 5.x. I don't mind writing the module myself, I was just wondering what the best method for pulling specific fields out of 3rd party modules and putting them into the registration form was. As in the example above, When I click "Include in regsitration" for the User Location module, it includes the entire location form, whereas I would only like to include the zip code.

Thanks,
-Walker

chandan chaudhary’s picture

one simple way to create a fast registration form is to create a simple form using form api and place it in a block.

now in a submit handler as u can easily get the values of a form u can use the "drupal_form_submit" function to submit a form.

here is the snippet of the code

function block_register_submit_handler($form,&$form_state) {
/* Change the form_state as per your requrement */
$form_state['values']['name'] = 'test';
$form_state['values']['mail'] = 'test@example.com';
$form_state['values']['pass']['pass1'] = 'password';
$form_state['values']['pass']['pass2'] = 'password';

$form_state['values']['postal']['zip'] = '33333333';
$form_state['values']['op'] = t('Create new account');
drupal_form_submit('user_register_form', $form_state);
}

Just make sure field other that listed on the fast registration should not be the mandatory field.

Need Drupal help?
Reach me

Acquia Certified Developer

Backend Frontend and DevOps.

skywalkerwilliamson’s picture

Hello again,

Thank you for the example, I think will take care of the functionality that I'm looking for, and if not, it's very close and will give me an exceptional starting point.

Thanks again,
-Walker

sagar ramgade’s picture

Hi,

You call user registration using php input format in a block like this :

<?php
$register_form = drupal_get_form('user_register_form');
$output = render($register_form);
print $output;
?>

And if you would like add more fields to user registration fields by going to admin/config/people/accounts/fields and add more fields. Make sure you make them visible in the user registration form.
Hope this helps.

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form