Hello there,

I found out how to prefill the "User register" form at "user/register", but I cannot prefill the form in the admin interface. I would like to add "users" to my drupal site by prefilling certain values from a cck "contact" node.

Basically I would import the name and the email from the contact node to the "Add user" adin form.. Is there any way you see to do this?

thanks alot!

Patchak

Comments

patchak’s picture

please, please!! Anyone has an idea how to do this??

Patchak

mgl4421’s picture

I found out how to prefill the "User register" form at "user/register", but I cannot prefill the form in the admin interface. I would like to add "users" to my drupal site by prefilling certain values from a cck "contact" node.

How did you prepopulate the registration form fields? I suspect the problems I'm encountering are related to fields within unnamed fieldsets. How would I prepopulate a user's email address and registration code?

Thanks

bentonboomslang’s picture

I am also having problems prepopulating my user registration fields.

I have used prepopulate elsewhere in my site but I cannot get it to work on the user/register site.

I have CCK and Content Profile installed and I have designated a few fields to be filled in on registration. Is this the case with you mgl4421 and patchak? Perhaps this could be the problem?...

Please let me know! Many thanks,

Ben

Hazlitt’s picture

I managed to prepopulate user registration fields using another module, have a look at my reply to a similar issue.

alberto56’s picture

Hi,

I'm having the same issue. Any direction from the maintainers would be appreciated!

Albert.

muckermarc’s picture

Hi,
I needed to pre-populate the user registration form too, but found the following worked for me (after a few hours of messing) with the latest 6.x-2.x-dev version.

If you have Profile fields in the registration form, it'll put these fields into fieldset tags with legend tags to display the name of the fieldset. You'll need to pass the legend text as part of the Prepopulate argument.

Here's an example structure with the fieldset groupings, plus the ID and NAME attributes of the input tags:

Account Information
Username (id="edit-name" name="name")
E-mail address (id="edit-mail" name="mail")
Personal Information
Name (id="edit-profile-name" name="profile_name")
Job Title (id="edit-profile-title" name="profile_title")
Company (id="edit-profile-company" name="profile_company")

To pre-populate Job Title on the registration form via the URL I used the following syntax:

http://mysite.com/user/register?edit[Personal%20Information][profile_title]=Nerd

or, via a hidden form element and POST:

<input type="hidden" name="edit[Personal%20Information][profile_title]" id="edit[Personal%20Information][profile-title]" value="Nerd" />

Note that the legend text "Personal Information" is case sensitive and that I've URL encoded the space character. Also be careful with the ID and NAME attributes, it's the NAME attribute you want to use, an it has an underscore "_" rather than a hyphen "-".

Confusingly, the Account Information elements (Username and E-mail Address) are handled slightly differently. To pre-populate the E-mail Address use the following syntax:

http://mysite.com/user/register?edit[account][mail]=me%40mysite.com

or, via a hidden form element and POST:

<input type="hidden" name="edit[account][mail]" id="edit[account][mail]" value="me%40mysite.com" />

Note that even if the legend reads "Account Information", you need to pass the value [account] instead - and it's case sensitive.

And finally, if you don't have any Profile fields visible on the user registration form, then Username and E-mail Address are not grouped in a fieldset so you need to use:

http://mysite.com/user/register?edit[mail]=me%40mysite.com

or, via a hidden form element and POST:

<input type="hidden" name="edit[mail]" id="edit[mail]" value="me%40mysite.com" />

Note the lack of "[account]" in the arguments.

alberto56’s picture

@muckermarc thanks, your input appreciated.

Breakerandi’s picture

Version: » 6.x-2.2

Any Solutions for content profile fields in the user registration form? thanks..

jruberto’s picture

Just to share what I just spent an hour figuring out..

(using 6.x-2.x-dev on user registration form)

/user/register?edit[account][name]=FirstLast&edit[account][mail]=emailaddy&edit[Profile][profile_first_name]=First&edit[Profile][profile_last_name]=Last

Account fields:

username:  edit[account][name]
email address: edit[account][mail]

Profile fields: (note category name is case sensitive)

profile fields: edit[Profile][profile_field_name]

phew! To test, just paste that whole first code block into your site's domain to see if it fills in the form for you. Learn your profile field names at /admin/user/profile

davito18’s picture

I am trying to pre-populate the regcode field on my registration form. I have set the fieldset title in Regcode module to 'accesscode' and have tried the following combinations but neither work:

/user/register?edit[accesscode][regcode_code]=132132
/user/register?edit[regcode_code]=132132

I can't work out what the issue is as other fields seem to pre-populate correctly when testing (7.x-2.x-dev). The html code of the field:

<input type="text" id="edit-regcode-code" name="regcode_code" value="" size="60" maxlength="128" class="form-text required">
gateone’s picture

Actually it is very simply once you know what to look for and where to look for when trying to populate a form field. While the maintainer did a nice job giving all sorts of examples, he never really explained how to address the subject from a pure logic point of view.

Basically the thing with the fieldset is really misleading and won't work in most cases. I also needed to prepopulate the registration code field from the Registration Code module. Taking the idea of the fieldset, I went into regcode.module to look up, how that form field actually is built internally. Now of course I am on Drupal 7 by now, but the idea still is the same.

So initially I was a bit puzzled while reading that on the username or email-fields of the user/register page the URL to use was
http://mysite.com/user/register?edit[account][name]=myname and http://mysite.com/user/register?edit[account][mail]=me%40mysite.com

What puzzled me here was the [account] but then I remembered that this was in the Form API of Drupal and that these fields' internal form API names really are [account][name] and [account][mail].

So I looked into the Registration Code module and searched for the part where the registration code form actually is produced.
Let me quickly show you the code (again, this is from Drupal 7, there might be some differences to Drupal 6, but the Form API was already pretty much in D6 as it is now in D7:

$form['regcode']['regcode_code'] = array(
    '#type' => 'textfield',
    '#title' => variable_get('regcode_field_title', t('Registration Code')),
    '#description' => variable_get('regcode_field_description', t('Please enter your registration code.')),
    '#required' => !($code_optional || user_access('administer users')),
    '#element_validate' => array('regcode_code_element_validate'),
  );

See how that form is named: $form['regcode']['regcode_code']! So here you have what you really need to use: just get rid of the ' and use this in the URL:
http://www.yourdomain.com/user/register?edit[regcode][regcode_code]=test

And there it was: the word "test" appears prepopulated right in the field.

So for the Registration Code module, the URL to use for prepopulating the registration code field is:
/user/register?edit[regcode][regcode_code]=somecode

A clearer documentation instead of tons of examples would have saved me an hour of searching around ;-)

jbrauer’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing D6 issues as it's no longer supported.

kourosh.a’s picture

Any idea how to fix this on D8 version?!

Mike Dodd’s picture

anyone get this working in D8?