• Resolved pkon

    (@pkonings)


    Hello Roy,

    What a great plug-in!
    I was wondering if there is any way we could expand on the code to create a condition in which either email(2) email(3) or email(4) etc. get’s send, and not the others.
    My goal is to create a form where people choose about what topic they want to receive information.
    I then don’t want to send them an e-mail that contains attachments for all the other subjects, just 1 email with the information they requested.
    Is this something reachable?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Roy Orbitson

    (@lev0)

    Hi,

    This plugin only creates the additional form parts for extra emails by duplicating what the original plugin uses in email (2). Since that does not have such conditional sending, nor do the extra ones. It’s not something I plan on building into this.

    However, there is a filter called wpcf7_additional_mail in submission.php that can be used to inspect the current form submission and conditionally remove messages from that array.

    The problem you’re describing isn’t necessarily a multiple emails issue. Wouldn’t it make more sense to send one email, but change its content and the set of attached files? That is also possible by using the filter/action hooks in CF7 and using add_extra_attachments().

    Regards.

    Thread Starter pkon

    (@pkonings)

    Hi Roy,

    Thank you for taking the time to respond.
    I think what you are suggesting would surely work and is even more elegant of a solution. However i’m not able to write a function code like that myself.
    With your clue’s, I might dip my toes into it someday and try to create somekind of code.
    For now the search goes on. ??


    Kind Regards

    Plugin Author Roy Orbitson

    (@lev0)

    Hire someone. It’s explained in this blog post, the form could have a checkbox set like this:

    [checkbox* interests use_label_element "a|Subject A" "b|Subject B" "c|Subject C"]

    Then something like this as the body of your custom plugin:

    add_action(
        'wpcf7_before_send_mail',
        function($contact_form, &$abort, $submission) {
            $interests = (array) $submission->get_posted_data('interests');
            if (in_array('a', $interests))
                $submission->add_extra_attachments('path/to/info-a.pdf');
            ...
        },
        10,
        3,
    );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional emails’ is closed to new replies.