Hi,

I've been using your module for a while now and I really like it. On thing I do think is missing; variable custom addresses.

Example; a site has been setup so that a user has to enter profile fields for account creation. In one of these profile fields the user is asked the monthly turnover of his/her company via a select menu. Now based on the choice the user has given I want to send the notification email to a junior, medior or senior sales person. I could think of many other posibillities, but this is the first that came to mind.

Now since this should be extendable to specific wishes I think it would be better to have a php field which may work with the given user/profile vars to return one or multiple email address via custom code.

What do you think?

Cheers

Comments

bartezz’s picture

Status: Active » Needs work

Have been working on a sub module to achieve this. What it does;

- adds a permission setting for PHP usage
- adds a radio button option to the 3 existing to add PHP code to return an email address for those with the permission
- adds a textarea in which one can insert PHP to return an email address, the $account variable is available for usage

This way one can send notifications conditionally.

I'm using this myself for regional managers. With the PHP code I look up the administrator from that region and send the notification email to him/her. But you could also use this for other functionallity ofcourse.

I will post the patch for the submodule here next week after thorough testing.

Cheers

bartezz’s picture

Status: Needs work » Needs review
StatusFileSize
new4.91 KB

Ok here is the patch. This patch will add 'User registration notification PHP' as a submodule which can be activated separately.
The patch is thoroughly tested and the code has been checked with coder.module and coder_tough_love.module

When the submodule is enabled, it;

  • adds a permission setting to permit roles to enter PHP code on the module's setting page
  • adds a radio button option 'Use PHP...' to the 3 existing to activate the PHP condition
  • adds a textarea in which one can insert PHP code to return an email address or multiple (comma separated), the $account variable is available for usage
  • checks the returned email address(es) for validity and if an invalid email addresses is found it will be replaced with the default $site_mail so no notification emails are lost and also a watchdog notice is logged
  • if PHP code was added by a user with PHP permissions another user without PHP permissions is able to view the PHP code but not edit it, but he or she is still able to change the module setting to send email to a custom email address for example

Notice: be carefull granting the PHP permission as drupal_eval() in your module's code could have a security risk if the PHP input provided to the function contains malicious code.

Hope you appreciate this patch and that it'll be committed!

Cheers,
Bartezz

bartezz’s picture

StatusFileSize
new4.92 KB

Crap I attached the incorrect patch in #2, please see correct patch attached!

bartezz’s picture

Category: feature » task

Have been running a live site with this patch for a month now without problems. Works great!
Is there a chance this will be committed?

Cheers

rmiddle’s picture

I will review the patch so and likely include.

Thanks
Robert

bartezz’s picture

Nice! Thanx for reviewing it, hope you like it.

Cheers

hass’s picture

Version: 6.x-1.9 » 7.x-1.x-dev
Component: Miscellaneous » Code
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

Please also fix the code style issues.

hass’s picture

Status: Needs work » Closed (outdated)