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

gcassie’s picture

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

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.

Soren Jones’s picture

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

Todo: Improve hook documentation

jnicola’s picture

Version: » 6.x-1.x-dev
Issue summary: View changes
Status: Active » Closed (won't fix)

This has come up a few times.

Due to complications with users being able to approve applications but possibly not activate users, this is being overlooked.

We're also only supporting the 7.x branch going forward.