Closed (fixed)
Project:
User Import Framework
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 May 2012 at 07:03 UTC
Updated:
18 Dec 2012 at 21:08 UTC
NOTE: Role import is natively supported by the UIF module, so there is no need to use the hook technique described in this issue.
ORIGINAL POST:
as per my other post, that dwightaspinwall answered:
Easily done in a hook_uif_post_create and/or hook_uif_post_update funkeyrandy. Just update the user and call user_save(). Hope that helps.
Next time, please open a new issue, since your comment was unrelated. Thanks.
im opening a new issue :)
here is what i have for adding multiple roles to a user, and assigning status:
function uif_example_uif_post_update($account, $user_data, $form_state) {
$roles[]=explode('|',$user_data['roles']);
foreach ($roles as $role) {
user_multiple_role_edit(array($account->uid), 'add_role', $role->rid);
}
} ive tested and its not working..nor is a simple example:
if($user_data['roles']=='4'){
$name="Member";
}elseif($user_data['roles']=='5'){
$name="Manager";
}
$new_role[$user_data['roles']] = $name;
user_save($account->uid, array('roles' => $new_role));
the users import, but the correct role isnt being set
any ideas?
thanks!
Comments
Comment #0.0
funkeyrandy commentedupdated
Comment #1
dwightaspinwall commentedThis should work for you:
Substituting your module name for "test" of course. This assumes you want to add roles when creating or updating, and they call the common function.
Comment #2
dwightaspinwall commentedMoved the above code into uif_example module. Thanks for the inspiration.
Comment #3
funkeyrandy commentedyou are the man! thanks so much!
Comment #4
dwightaspinwall commentedComment #6
brei9000 commentedIt seems that using
user_save($account)in this manner deletes the profile picture.Comment #7
dwightaspinwall commentedRole import is natively supported by UIF now, so you don't need to use the method described in #1 above. Update the module if you haven't already and give it a whirl.
Comment #7.0
dwightaspinwall commentedupdate
Comment #7.1
dwightaspinwall commentedModify to indicate role import natively supported