The check boxes to assign roles on subuser creation have disappeared in the latest dev release. Comparing the alpha and dev code it appears some of the code from the subuser_form_user_register_form_alter has been removed.
Current Dev code
function subuser_form_user_register_form_alter(&$form, &$form_state) {
global $user;
$form['subuser_relation'] = array(
'#type' => 'checkbox',
'#title' => t('User relation'),
'#description' => t('Store a relationship that will allow for further management of the user.'),
'#default_value' => $user->uid && variable_get('subuser_relation', TRUE),
'#access' => $user->uid && user_access('override subuser relation'),
);
$form['#submit'][] = 'subuser_user_register_form_submit';
}
Alpha Code
function subuser_form_user_register_form_alter(&$form, &$form_state) {
global $user;
// If the user does not have access to the roles field then filter the roles
// field based on subuser permissions and display if more then one left. If
// the user has 'administer permissions' then the #access will be set to TRUE
// and they will have access to all roles, otherwise if the user has access
// to this page through subuser then only provide them with the roles they
// are allowed based on subuser. All users will have at least one role, but
// that role may be 'authenticated user' which is not included in #options.
if (!$form['account']['roles']['#access']) {
foreach ($form['account']['roles']['#options'] as $rid => $role) {
if (!user_access('create subuser ' . $rid)) {
unset($form['account']['roles']['#options'][$rid]);
}
}
$form['account']['roles']['#access'] = count($form['account']['roles']['#options']) > 0;
}
$form['subuser_relation'] = array(
'#type' => 'checkbox',
'#title' => t('User relation'),
'#description' => t('Store a relationship that will allow for further management of the user.'),
'#default_value' => $user->uid && variable_get('subuser_relation', TRUE),
'#access' => $user->uid && user_access('override subuser relation'),
);
$form['#submit'][] = 'subuser_user_register_form_submit';
}
Putting this bit back into the dev code appears to make everything work correctly but I'm not sure if this was removed on purpose or if there has been any changes that would require this be updated.
// If the user does not have access to the roles field then filter the roles
// field based on subuser permissions and display if more then one left. If
// the user has 'administer permissions' then the #access will be set to TRUE
// and they will have access to all roles, otherwise if the user has access
// to this page through subuser then only provide them with the roles they
// are allowed based on subuser. All users will have at least one role, but
// that role may be 'authenticated user' which is not included in #options.
if (!$form['account']['roles']['#access']) {
foreach ($form['account']['roles']['#options'] as $rid => $role) {
if (!user_access('create subuser ' . $rid)) {
unset($form['account']['roles']['#options'][$rid]);
}
}
$form['account']['roles']['#access'] = count($form['account']['roles']['#options']) > 0;
}
Comments
Comment #1
littledynamo commentedI am also experiencing this problem - upgraded to dev and now there are no options to assign a role when creating a subuser.
Comment #2
aaronbaumanNot sure why "create subuser" role permissions are only exposed on the edit form.
In this patch:
- Apply the same logic to user_register_form to expose roles.
Comment #3
nagraj404 commentedautomatically Can't assigning parent roles to subusers , same working in D6 but not in D7
Comment #4
pooja.sarvaiye commentedMinor fixes to comment - added ending period and changed few words
Comment #5
pooja.sarvaiye commentedSubmitting again with correct file.
Comment #6
pooja.sarvaiye commentedLimited comment to 80 chars approx and modified other similar comment
Comment #7
pooja.sarvaiye commentedComment #8
rteijeiro commentedPatch applies well and it fixes a couple of coding standards issues too. Screenshots provided in #4 seem fine. It's RTBC for me!
Comment #10
lauriiiLates patch is commited and pushed! Thanks for working on the issue! I created issue as a follow-up for this: #2509978: Automatically assign subusers on specific role because I really liked how clean the user creation form used to be before roles was there.
Comment #11
rteijeiro commentedGreat, thanks @lauriii!! Let's see if @pooja can work in the follow-up too. We are going to use this module actively in our current project.
Comment #13
DrCord commentedThe patch in #7 worked for me, easy peasy!
Comment #14
DrCord commentedThis actually ended up being a better solution, as I didn't want the user to be able to choose what role was granted but rather force it to be granted.
https://www.drupal.org/node/2509978#comment-10257663