[dokuwiki] Plugins, Creating Users and Groups

  • From: Chris Tregenza <junk-freelists@xxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sun, 15 May 2011 13:12:11 +0100

I'm developing a plugin that adds new users to specific groups based on
certain criteria. Everything is going well but I'm struggling with the
AUTH_USER_CHANGE event and modifying the event data.

I've registered a hook for before the event is called:

myaction.php:

        $controller->register_hook('AUTH_USER_CHANGE',
                                   'BEFORE',
                                   $this,
                                   'handle_before_user_change',
                                   array());

This is called and I modify the event data.

myaction.php:

    /**
    *
    *    User about to be created
    *
    *
    **/
    function handle_before_user_change(&$event, $param){

        if ( $event->data['type'] === 'create' ) {
            $grps = array();
            $grps[] = "test";
            $event->data['params'][4] = $grps;
        }
        return true;

    }

This works correctly. Dumping the event data in Auth.php triggerUserMod (the
function that fires the event) shows that the event data has been changed.
However, when plain.class.php createUser is called, the $grps parameter is
empty.

I've assumed that the plain.class.php createUser is called with the data
held in the event but this is not happening. Am I completely
misunderstanding how the events and their data are used? How do I amend the
data used to create users?

Chris

Other related posts: