Title: Hook for changing notification recipient programmatically
Last modified: June 21, 2024

---

# Hook for changing notification recipient programmatically

 *  Resolved [colorinside](https://wordpress.org/support/users/colorinside/)
 * (@colorinside)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/hook-for-changing-notification-recipient-programmatically/)
 * Hello,
 * I’m trying to update and/or add recipients to notifications email via PHP, because
   my logic can’t be implemented only by notifications options or routing.
 * I’ve used “forminator_form_get_admin_email_recipients” hook and returning the
   new email address, but notifications array does not get updated.
   I’ve also tried
   with “forminator_get_user_email_recipients” filter, but nothing changed.
 * I’m using the “post” form module.
 * Thank you for your help!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/hook-for-changing-notification-recipient-programmatically/#post-17841283)
 * Hi [@colorinside](https://wordpress.org/support/users/colorinside/)
 * I hope you’re well today!
 * You can use one of the following filters:
 * 1. _forminator\_custom\_form\_mail\_admin\_headers_
 * to directly modify e-mail headers (e.g. set/modify From header)
 * 2. _forminator\_custom\_form\_mail\_admin\_cc\_addresses_
 * to set CC address(es)
 * 3. _forminator\_custom\_form\_mail\_admin\_bcc\_addresses_
 * to set BCC address(es)
 * All those filters are defined in the /forminator/library/modules/custom-forms/
   front/front-mail.php file so you can take a look there to see how they are used
   there.
 * If you have any additional/follow-up questions, let us know.
 * Kind regards,
    Adam
 *  Thread Starter [colorinside](https://wordpress.org/support/users/colorinside/)
 * (@colorinside)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/hook-for-changing-notification-recipient-programmatically/#post-17842049)
 * Hello Adam,
   thank you for your quick reply.I need to update the default recipient
   I’ve set via Forminator Admin, the hooks you reported are for other headers.
 * Basically: the message must be sent to a specific user, selected with a complex
   query that cannot be done with routing.
   Why the /forminator_form_get_admin_email_recipients
   hook is not working?
 * Thank you very much!
 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/hook-for-changing-notification-recipient-programmatically/#post-17843952)
 * Hi [@colorinside](https://wordpress.org/support/users/colorinside/)
 * We would need to check your code but I did the following:
 *     ```
       add_filter('forminator_form_get_admin_email_recipients', function ($email, $notification, $data, $module, $entry) {
   
           $email[0] = 'new@email.com';
   
           error_log('forminator_form_get_admin_email_recipients');
           error_log(print_r($email, true));
   
           return $email;
       }, 10, 5);
       ```
   
 * It logged in the debug.log + received the email in the new destination rather
   than the one defined in the interface.
 * [https://monosnap.com/file/6qpGOliSshFOS9vsDSJ52HEE1bjZOB](https://monosnap.com/file/6qpGOliSshFOS9vsDSJ52HEE1bjZOB)
 * Best Regards
    Patrick Freitas
 *  Thread Starter [colorinside](https://wordpress.org/support/users/colorinside/)
 * (@colorinside)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/hook-for-changing-notification-recipient-programmatically/#post-17844155)
 * Hi Patrick,
   thank you very much for you support. The issue was related to another
   function hooked to forminator_custom_form_mail_admin_message that did not properly
   return $message.
 * Now everything is working fine, you can considered this topic as “solved”.
 * Thank you!
    -  This reply was modified 1 year, 10 months ago by [colorinside](https://wordpress.org/support/users/colorinside/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Hook for changing notification recipient programmatically’ is closed 
to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [colorinside](https://wordpress.org/support/users/colorinside/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/hook-for-changing-notification-recipient-programmatically/#post-17844155)
 * Status: resolved