I created my own module for this. I basically modified the rolesignup module for my own needs.
First, I set up some path aliases like
"firstmembertype" = "user/register/role/8" (where 8 is the role number)
"secondmembertype" = "user/register/role/9"
etc
Then the module just basically took that alias and assigned the role:
/**
* Implementation of hook_form_alter()
member = 7
memberadmin = 8
*/
function myrolesignup_form_alter($form_id, &$form) {
if ($form_id == "user_register") {
// Make sure there is a role associated with this sign up
// If not, give them the member role
if ((arg(3) != 7) &&
(arg(3) != 8) &&
(arg(3) != 9)) {
$myrole = 7;
} else {
$myrole = arg(3);
}
$form['role'] = array(
'#type' => 'value',
'#value' => $myrole,
);
}
}
/**
* Implementation of hook_user()
*/
function myrolesignup_user($op, &$edit, &$account, $category = NULL) {
global $myrole;
switch ($op) {
case 'insert':
// Make sure the role is defined
if (($edit['role'] != 7) &&
($edit['role'] != 8) &&
($edit['role'] != 9)) {
$myrole = 7;
} else {
$myrole = $edit['role'];
}
// Insert the role into the DB
db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $account->uid, $myrole);
// Give them the authenticated role as well
db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, 2)", $account->uid);
}
}Not exactly the most elegant, but it works.
The module was written for D5, but the only hook that changed was form_alter, so if you modified that, you should be good to go.
I am trying to find a way to automatically assign users to specific roles, or at very minimum allow them to select a role. I have tried using the auto assign role module, and setting it to allow users to select a role at registration, but I do not want them to be able to select any of the available roles, just 2 or 3 that I have set aside for this purpose. Also, I tried to find a way to configure the rules module so that after performing a certain action the user would automatically be assigned to a specific role, and had no luck with this either. Any help would be greatly appreciated.