So the module works great and is exactly what I have been looking for. However, when the module creates users, it has no fields other than login and password. If we have setup users with the Profile module, we need to be able to access those fields, or at least some of them like Name, Title, etc...

Also, when the site configuration is set to require administration approval, the Subusers also require activation. Is it possible to not have these users require administrative activation since the parent is already activated?

CommentFileSizeAuthor
#12 subuser_profile.patch745 bytesstella

Comments

boombatower’s picture

Status: Active » Postponed (maintainer needs more info)

The profile fields could be done by copying the code that profile uses to add them (I believe hook_form_alter()). I would have used the core registration form, but it contains a permission check that screws everything up.

Not currently, but you should be able to implement hook_user() and on create check if user has a subuser table record with a parent and if so activate them.

Let me know if that works or you need more details.

z33k3r’s picture

Well the thing is that I need different criteria for these subusers... so different from the main registration. I guess this is a new area for me, if you could follow with a bit more specific detail (not necessarily line for line) but just more specific on what would be involved?

z33k3r’s picture

Could you at least include the basic fields by default (ie: First Name, Last Name)... I could customize the code to meet my needs, but I would rather see it done the right, communal/Drupal, way!

boombatower’s picture

Title: User profiles » Display required user profile fields on subuser create form
Version: 6.x-1.1 » 6.x-1.x-dev
Category: bug » feature

Could add a bit of this into subuser, if you end up implementing something post back a patch and I'll review it and possibly commit.

You want to look at user_register() in /modules/user/user.module specifically at the code that allows other modules to define form elements. Profile module defines them this way.

// Create a dummy variable for pass-by-reference parameters.
$null = NULL;
$extra = _user_forms($null, NULL, NULL, 'register');

The profile modules /modules/profile/profile.module adds its elements to the default registration form via hook_user() [profile_user()] which returns the form generated by:

profile_form_profile($edit, $user, $category, TRUE);

The best solution would be to include the code above, from user.module, in subuser registration form [subuser_create_form()].

Good luck, let me know if you need any help and how it turns out.

Rosamunda’s picture

It would be great if this could work with content_profile module, so the mandatory fields to be filled in inside the profile for role X could be inside the subuser form (for users that would be created and integrated to that role X).

boombatower’s picture

It is really sad that the build in Drupal form is written so poorly and does an access check inside the form definition, otherwise I could use that and all these integrations would be automatic.

I think I'll look into changing that in D7.

dublin drupaller’s picture

@rosamunda #5

Did you find a workaround for that? I'm facing the same problem..i.e. fields to be filled in inside the profile for role X could be inside the subuser form (for users that would be created and integrated to that role X).

Liembo-1’s picture

Having the ability for the admin of a subuser be able to populate the defined user profile fields would be a huge bonus for this module. Its very nearly a deal-breaker for me that it does not, unfortunately. I'm going to look through your suggestions above, however, and see if is possible to work around. I want to put the bulk of user set up (firstname/lastname/vitals/etc) where possible on the admin, rather than the potentially un-savvy end user, so any progress on this direction of work would be greatly appreciated.

rcharamella’s picture

Has there been any movement on this issue? I'm facing much the same problem as outlined above.

z33k3r’s picture

No. There hasn't been. I haven't had any time to learn what needs to be written for this and it looks like the author doesn't care either... :(

stella’s picture

subscribe

stella’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new745 bytes

Attached patch should do it. It's the same approach as described in comment #4 above. I've tested it and it seems to work quite well.

jeffreyvddb’s picture

Patch looks good: the fields are there.. But there is one thing: I've got two dropdowns on the registration form (State and Country), which have options in the normal registration form. On the 'Create Subuser' form, these dropdowns have no options.. Two other dropdowns (Title and a list of 11 Industries) are shown. Could it be related to the amount of options? Any ideas how to fix this?

anou’s picture

i got this error with the patch :
warning: array_merge(): Argument #2 is not an array in /sites/all/modules/subuser/subuser.pages.inc on line 236.

but i use content profile and not profile...

mlalu’s picture

Thanks for the patch. This might be asking for too much, but I use the profile role module which allows me to only require certain profile categories based on which role they are signing up for. Is it possible for me to change this line of code that the patch inserts, to only add a certain profile category?

$extra = _user_forms($null, NULL, NULL, 'register');

smartsystems160’s picture

@anou. These patches seem to do the work for content profile module http://drupal.org/node/571660

adigunsherif’s picture

Issue summary: View changes

For users who may be after Drupal 7, create a module and place this in your .module file


/**
 * Implements hook_form_user_register_form_alter
 */
 
function modulename_form_user_register_form_alter(&$form, &$form_state) {
  if($_GET['q'] == 'admin/people/create'){
	 //$_GET['q'] gets the current path of the user
        $form_state['profiles'] = array(
        'profile_name' => profile2_get_types('profile_name')
      );
      profile2_attach_form($form, $form_state);
    }
}

NB: CHANGE profile_name to the name of your profile
If you want to be sure that this profile only shows when the current user that is creating a subuser has a particular role, you can use this

/**
 * Implements hook_form_user_register_form_alter
 */
 
function hook_form_user_register_form_alter(&$form, &$form_state) {
  global $user;
  $current_user_role = in_array('the_role', $user->roles);
  $form['account']['status']['#access'] = FALSE ;
  if($_GET['q'] == 'admin/people/create' && $current_user_role){
	  $form_state['profiles'] = array(
        'profile_name' => profile2_get_types('profile_name')
      );
      profile2_attach_form($form, $form_state);
    }
}

NB: CHANGE the_role to the name of the role you want to check.