• Following on from this supoprt topic created under my plugin, could you please consider using the wpcf7_mail_components hook to parse and modify the messages’ bodies? Then it would apply to any and all messages that contain your plugin’s shortcodes, without having to assume the mail messages’ keys in present in $form->get_properties().

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    It used to work like this, but in version 1.5 of the plugin this change was made:

    use the wpcf7_before_send_mail hook instead of wpcf7_mail_components to hide mail groups. The wpcf7_before_send_mail hook is called earlier, so it allows to also hide groups in the attachment field and in messages.

    I guess it wouldn’t hurt if I could just update the attachment fields and messages in the wpcf7_before_send_mail and update the email fields in the wpcf7_mail_components. Can I just use the default priority of 10, or should I get a higher/lower number in order not to conflict with your plugin?

    Thread Starter Roy Orbitson

    (@lev0)

    Yes, I see. Too much processing of those fields occurs before the wpcf7_mail_components hook. The downside of using only wpcf7_before_send_mail is that it fires before most additional mails get attached. You could process mail and messages properties as you do now, but also attach to wpcf7_additional_mail then process all the message arrays present in that filtered array, including mail_2. That should preserve your processing of all the properties you do now and offer attachment processing to the additional messages.

    Do you agree that it makes sense to extend your conditional tag processing to all messages?

    I used 8 for the priorities in mine so that the additional messages would be available to any other code that attaches with the default priority (10), but also to allow modification/removal at priority 9. You could increase your chances of catching all messages if you use a very late priority, like (PHP_INT_MAX - (PHP_INT_MAX % 2)) / 2.

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

The topic ‘Alternative hook: wpcf7_mail_components’ is closed to new replies.