Download & Extend

Activate user account on role approval?

Project:Apply for role
Component:Documentation
Category:task
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

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?

Comments

#1

you can implement 'hook_apply_for_role' in a custom module to react to the 'approve' hook:

<?php
function 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.

#2

Version:5.x-1.8»
Component:Miscellaneous» Documentation
Category:support request» task

Todo: Improve hook documentation

nobody click here