user register form for each type of site member?
I have been trying to build a Drupal 7 site that accommodates three different type of users (a,b,c). I have been trying to set up a simple front page that has three unique "create your account" links to register each user separately. For example:
"create your account a" link opens a user/register page that would have custom fields pertinent to user "a"; Likewise for use "b" and "c". The objective is to assign each user (a,b,c) to a separate role, and have there profile page unique to that role.
I first tried to setup profile2 module and autoassignrol module with out any luck. These two modules do everything I want but don't have a way to have separate user/register pages. The autoassignrol module has a work in progress feature that will supposedly make it possible to have multiple user/register page, but I have been trying to understand the workings but am lost in the entity API approach that is taken. Is there a tutorial on the entity API?
I then tried to build a module that would simply build a block that would add the fields to the user/register page. example module:
// $Id$
/**
* @file
* A block module returning a user_register_form in a block.
*/
/**
* Implements hook_block_info().
* This hook declares what blocks are provided by the module.
*/
function blocktest_block_info() {
$blocks['blocktest'] = array(
'info' => t('blocktest'),
'cache' => DRUPAL_CACHE_PER_ROLE,
);
return $blocks;
}
/**
*Implements hook_form_FORM_ID_alter(&$form, &$form_state, $form_id).
* This hook makes Modification to the form with the given form ID.
* FORM_ID is "user_register_form" this code would run only on the user
* registration form.
*/
function blocktest_form_user_register_form_alter(&$form, &$form_state, $form_id) {
// Add a checkbox to registration form about agreeing to terms of use.
$form['terms_of_use'] = array(
'#type' => 'checkbox',
'#title' => t("I agree with the website's terms and conditions."),
'#required' => TRUE,
);
}
/**
* Implements hook_block_view().
* This hook generates the contents of the block.
*/
function blocktest_block_view($delta = '') {
$content = t('Hello World');
$block['subject'] = null;
$block['content'] = drupal_get_form('user_register_form');
return $block;
}
The problem is that this module adds the field to the user/register everywhere it is used so it wont work to build three of these modules for each user. With this problem what strategy should I take to accomplish this task?
Thank you for any advice.
Craig
Create a custom User Registration form with FAPI D7 resource:
http://drupal.org/node/1063598
I built the "custom User Registration form" in a block like above. Then I use panels module to display my block; This is nice because I can set the path with in the Panels UI and theme the entire panel for each user role/registration separately. I built three of these block user registration modules for each user (a,b,c).
This has been my best approach/strategy to solving multi registration forms and auto setting a Rol at registration. I have chosen to do this hybrid approach of building a custom module that utilizes panels because I like the idea of leverage modules like panels and it has minimized the amount of code I had to write.