Activate user account on role approval?
Sansui - February 19, 2009 - 15:58
| Project: | Apply for role |
| Version: | 5.x-1.8 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I'd like users to apply for a role when they register, but also have to have their account approved before they can log in - right now it looks like once you approve the role for the user, you also have to manually activate the user's account.
I tried setting up workflow-ng to see if there were any readily available entries to be able to do this, but I didn't see any. Is there a simple way to do this?

#1
you can implement 'hook_apply_for_role' in a custom module to react to the 'approve' hook:
<?phpfunction custommodule_apply_for_role($op, $apply) {
if ($op == 'approve') {
$account = user_load($apply->uid);
if ($account) {
user_save($account, array('access' => time(), 'status' => 1));
}
}
}
?>
tested this with 6.x-1.8 and it is working just fine. should also work for 5.x-1.8.