drupal - What's the point to have hook_mail_alter if I already have hook_mail? -


If I have hook_mail then what does it mean to be hook_mail_alter?

For example, I saw that hook_mail_alter is used to add a footer to my mail message but I can use the hook_mail () to add it, Rather than using 2 functions ... what am I missing?

Perhaps this footer is done after adding some other functions are implemented?

hook_mail () should be used from a module of its own To change the mail message, while hook_mail_alter () should be used from the module to change the message sent by another module.

This is evident from the following code: taken from drupal_mail ():

  // Create an email (get topic and body, additional Allow header) // apply hook_mail () to this module. We can not use module_invoke () // We should have $ message by reference in hook_mail () (function_exists ($ function = $ module 'mail')) {$ function ($ key, $ message, $ Params); } // Invite hook_mail_alter () to change the result as a result of all the modules. Drupal_alter ('mail', $ message);  

$ Module is the first code that has been sent to drupal_mail () . It is clear that the function does not apply implementing the hook_mail () that enforces every module, but invites the hook for the module calling the function.

There are other differences, such as two hooks apply ( hook_mail_alter () can not set the language for the message, which is hook_mail_alter () applied), and the parameters they received ( hook_mail ($ key, & amp; $ message, $ parameter) vs hook_mail_alter (& amp; $ message) ).


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -