Forums / Developer / Automatic email with new account activation info from Admin

Automatic email with new account activation info from Admin

Author Message

John Smith

Thursday 26 November 2009 2:05:30 am

Hi guys,

Need urgent help please.

How to send an automatic Email (from admin interface) with information of account activation/login details. Administrator manually creates accounts in the administration interface. Users can not register themselves from the Public website as it is disabled by me.

Need something when the administrator creates an account, the system should email to the user regarding account activation/login details.

Any clues?

Much apprecaited.

John Smith

Thursday 26 November 2009 7:09:35 am

Anyone please???

Robin Muilwijk

Thursday 26 November 2009 11:32:45 am

Hi,

I found the following documentation page:

http://ez.no/doc/ez_publish/technical_manual/4_x/reference/configuration_files/site_ini/usersettings/verifyuseremail

However, in settings/site.ini there is a note about this parameter to be deprecated and you can use something else (eZ 4.2.0):

Line 408 : # DEPRECATED: VerifyUserEmail is deprecated, use VerifyUserType instead.
Line 412 : VerifyUserEmail=enabled
Line 415 : # If set to email then VerifyUserEmail is checked for compatibility.

Hope this helps, regards, Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

John Smith

Friday 27 November 2009 12:48:02 am

Robin,

Thanks for your kind reply and help. Would it be possible for you to please explain the above in bit more detail. I am using version 4.0.1. How these settings can be useful in sending the email while registration from the administration interface.

Cheers,

Robin Muilwijk

Friday 27 November 2009 11:05:32 am

Hi John,

I'm no expert to be honnest, I'm assuming this setting will send the user an e-mail once he/she get's added on the site, either through front or back end. It should be easy to setup and test though, just add the parameter to your site.ini file, create a user in the administation and see if the user get's the activation e-mail.

I might be totally wrong here though, as I said, no expert either ;)

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

John Smith

Saturday 28 November 2009 2:14:28 am

I dont think so I will achieve what I am looking for, with those settings. Any one from ezcrew please help...

Cheers,

Robin Muilwijk

Saturday 28 November 2009 12:51:54 pm

You are right John, tested it myself and could not get that to work. A user created by the admin get's enabled by default, thus no user e-mail with account details and activation link.

I hope someone from the eZCrew can help shed some light on this.

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

John Smith

Monday 30 November 2009 12:40:25 am

Cheers Robin,

Thanks for your kind effort. Hope someone else or somebody from ezCrew will help me.

Cheers,

Nicolas Pastorino

Monday 30 November 2009 10:16:20 am

Hi John,

One possible solution to this, given that the user/register view is not used, would be to use a workflow event. Here are helpful resources for this :

  • http://ez.no/doc/ez_publish/technical_manual/4_x/concepts_and_basics/workflows
  • http://ezpedia.org/en/ez/workflow_event_type

This workflow event would need to be plugged on the after/publish trigger (from your back office, Setup > Triggers ) after having been properly added to a workflow ( Setup > Workflows ).

The content of the execute() method would check what kind of object is being published ( check against the content class ), and if this is a user, create an email and send it to the concerned person.

Please let us know how this goes (in case you are having issue with the API for instance)
Best Regards,
--
Nicolas

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

John Smith

Friday 04 December 2009 4:54:59 am

Trying to write some extension in which adminstrator can send email to the user from the administration interface. But what is the best method to pull or send the password, as everybody know passwords are stored in "hash". I dont want to store the passwords in plain text as mentioned in site.ini. I can easily pull the login name, email address but not password.

Hope someone can help....

Much appreciated.

Quoc Huy Nguyen Dinh

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.

  1. code your eventtype file /extension/yourextension/eventtype/event/nameofyourevent/nameofyoureventtype.php
  2. create a new workflow using this event
  3. 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.
  4. 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.
  5. 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();