0

I have already setup account fields, and I have two roles (A) and (B) I need to create a page with two button links :

  • register as (A)
  • register as (B)

when the user choose one of these two links, he will go to the registration page and after filling the form, he will be registred and automatically get the role (A) or (B) pursuant the link chosen above

the problem is: how can I pass the info of what choice the user has chosen (first or second link) to the registration form.

I thought to pass it inside the request URI and then get it via $_GET but Is there another solution wihtout showing any query to the user in the URL ?

Thanks in advance.

  • use $form_state. – tenken Mar 27 '15 at 16:13
0

Well you can make small form with 2 submit buttons (Register as A, Register as B) and post that data on register form, in this way you can hide it from url

OR

The other way which is more complicated, using ajax, when link is clicked and based on the clicked link you create the $form_state and set the flag then you call the register from using drupal_get_form and you pass the argument

OR

Just create boolean field in user, and put the option (Register as A, Register as B) and make it required to be listed in register from

0

I will use the Drupal form API to create a module for this. These two forms has to be different and will use the user_save function to create new user account and will assign role.

$myuserroles[] = 'newrole'; 
user_save($myuser, array('roles' => $myuserroles)); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.