CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Optional Event cancel email?
Pages: [1]

Author Topic: Optional Event cancel email?  (Read 1933 times)

grahamgilchrist

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 3
Optional Event cancel email?
December 03, 2009, 09:51:33 am
CiviEvent by default sends an email to a contact whenever their event status is changed to cancelled.

I have a use-case in my organisation whereby all the event registrations are handled by an administrator with Civi access (the web-based signup is turned off) and people who ring/email to register for events do not know anything about the system which is used in the office, and we definitely do not want the contact emailed when the administrator sets their participant status to cancelled.

I can't see a way to edit this functionality via hooks etc. without editing core (which I am unwilling to do at this point because of the upgrade difficulties).
Does anyone have any suggestions?

If not, it would be great if this could be an optional feature, either globally or per-event? I'd roll a patch, but I have no idea where to begin with civievent admin settings. Perhaps someone could point me in the right direction?

Or, an alternative (which I imagine would be easier to implement) would be to provide a hook allowing developers to alter whether the event emails are sent or their contents?

Anyone got any ideas/suggestions?

P.S. thanks for all the great development work you guys are doing.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Optional Event cancel email?
December 03, 2009, 11:49:32 am

a mail alter hook is long overdue :)

I think in 3.1 we should introduce a mail alter hook. Note that the mail sending code has been changed SIGNIFICANTLY in 3.1.

I've been looking at the mail code, here is my proposal:

* Add a hook call to: CRM/Core/BAO/MessageTemplates.php, function sendTemplate

just before the call to CRM_Utils_Mail::send (line 426)

* Change the argument array to send to be just one array passed by reference
* Send the hook the above array. This array will contain the

            'groupName'  // option group name of the template                                                                                                         
            'valueName'   // option value name of the template

the above two parameters basically give you the context in which the email is being sent
* The hook implementation can then:

a. Modify any of the params in an appropriate manner.
b. Skip the mail sending process

thoughts? Unfortunately i dont think we can backport the patch, so you might need to upgrade :)

lobo

                                                                                                         





A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Optional Event cancel email?
December 03, 2009, 03:04:52 pm
The mail alter hook sounds like a very useful addition.

HOWEVER, for Graham's situation in 3.1 we have add a "control" in the UI allowing the user to NOT send notification of the cancellation. I've attached a screen snippet - but you should also play with it on the sandbox to see if it handles your use case (http://sandbox.civicrm.org)

Note that the default behavior is to "check the box" - but this should be easy to modify with the buildForm hook (or perhaps just customizing the template to replace the checkbox with a hidden field set to false).
Protect your investment in CiviCRM by  becoming a Member!

grahamgilchrist

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 3
Re: Optional Event cancel email?
December 03, 2009, 03:24:21 pm
Wow, thank you both for the replies.

Quote from: Donald Lobo on December 03, 2009, 11:49:32 am
I've been looking at the mail code, here is my proposal:

*snip*

the above two parameters basically give you the context in which the email is being sent
* The hook implementation can then:

a. Modify any of the params in an appropriate manner.
b. Skip the mail sending process


This sounds an excellent idea, and also answers my next question, which was whether such a hook could also be used to alter the email content (to remove some custom fields, or edit the text for instance).
I see how one could modify the parameters of the email send process using such a hook, but how would one cancel it completely? Set the parameter array to be blank? 

Quote from: Donald Lobo on December 03, 2009, 11:49:32 am
thoughts? Unfortunately i dont think we can backport the patch, so you might need to upgrade :)

No problem, I have tried to keep my code additions to hook modules and template files, plus there are a couple of other 3.1 features I am looking forward to :)

Quote from: Dave Greenberg on December 03, 2009, 03:04:52 pm
HOWEVER, for Graham's situation in 3.1 we have add a "control" in the UI allowing the user to NOT send notification of the cancellation. I've attached a screen snippet - but you should also play with it on the sandbox to see if it handles your use case (http://sandbox.civicrm.org)

Wow, implementing features before I've asked for them - thats a first ;)
Thats really useful, thanks - although in the long run the email hook would give much more control for other parts of this implementation too.

I'd love to see this in 3.1. Thanks for all the work you guys put into this project.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Optional Event cancel email?

This forum was archived on 2017-11-26.