Tuesday 08 December 2009 5:58:35 am
We recently needed something like that and have solved it by creating a workflow event. It's basically what Nicolas Pastorino is suggesting.
- code your eventtype file /extension/yourextension/eventtype/event/nameofyourevent/nameofyoureventtype.php
- create a new workflow using this event
- if you don't have it, create a workflow named "After publish" and create a trigger for content post publish that is using this workflow.
- Edit this workflow and add a multiplexer from which you will test the content class, section etc... and launch the first workflow if it is a user. Also check that the multiplexer launches the workflow only on new created objects, unless you want a reminder if modified.
- with in the workflow event file you can do what you wish (sending email...)
Now every time you create a user it should do what you have coded. An issue is retrieving the password. When you type in the password in the user edit page. This one is encrypted and thus the workflow event cannot retrieve it. What can be done is generate the password within the workflow event script, store it and send it to the user. to generate and store the password within an workflow event script: $objectID = $parameters['objet_id']; $object = & eZContentObjectTreeNode::fetch($nodeID); $datamap = $object->datamap(); $user = $datamap['user_account']->attribute('content'); $pwd = substr(md5($objectID), -8); $hashType = $eZUser::hashType(); $newHash = eZUser::createHash($user->attribute('login'), $pwd, eZUser::site(), $hashType); $user->setAttribute("password_hash_type", $hashType); $user->setAttribute("password_hash", $newHash); $user->store();
|