• Resolved colorinside

    (@colorinside)


    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 Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @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

    (@colorinside)

    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

    (@wpmudevsupport12)

    Hi @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] = '[email protected]';
        
        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

    Best Regards
    Patrick Freitas

    Thread Starter colorinside

    (@colorinside)

    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 9 months, 1 week ago by colorinside.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hook for changing notification recipient programmatically’ is closed to new replies.