Support » Plugin: Visual Form Builder » How do I send emails to different people based on field entry?

Viewing 15 replies - 1 through 15 (of 22 total)
  • Plugin Author Matthew Muro

    (@mmuro)

    I’m actually working on a new plugin action for the Pro version that will make this much easier. No plans to bring that to the free, though, as advanced features like that tend to be Pro only.

    I will update this thread when that feature is available.

    Thanks Matthew, I am currently using the VFP Pro paid version and I also purchased the Display Entries as well. Any word on when you might have the new plugin ready? I know its hard to say exactly, but a ballpark would be great.

    Also, while I have you, is there any way to set a time frame around the data that is being displayed using the Display Entry Add-on. I don’t need all of my data displayed, just the most recent.

    Thank you again for your help.

    Best,
    Megan

    Plugin Author Matthew Muro

    (@mmuro)

    Just to clarify that the new ‘action’ is in reference to a hook. What this means is that it’ll be part of VFB Pro whenever it’s updated and not a separate add-on. I don’t have a timeline to share, but I’d like to launch sometime this month or early next. Things happen though 🙂

    As far as the Display Entries thing, submit a feature request or improvement and I may (or may not) decide to add it.

    One more question…I have access to a developer who can use your vfb_confirmation action hook to get the POST variables and send an email based on a case statement selected by one of the POST variables. Does this sound workable? Do you have any snippets of code that take the POST variables and generate the emails now or can you point me to one of your functions that does that? Do you use standard php email routines or do those come from your functions as well?

    Thanks!

    Plugin Author Matthew Muro

    (@mmuro)

    Yeah, you can use the vfb_confirmation action but the emails will have already been sent. With the new actions coming you can override the email function completely to make it work like you want.

    The email is sent with the wp_mail function.

    Just adding myself to the list of people to notify when the plugin supports multiple recipients based on form entry.

    Just out of curiosity, why make this functionality something someone needs to code and attach to a hook as opposed to e.g. Form Settings > Email > Recipients > click “+” > pick an email field ?

    We’ll be buying Pro if the feature is easy to use, but needing to code it is a little more complicated than I want to get into. It’s not that it’s hard to do … I’m thinking about if I get hit by a bus, I want the next guy to be able to step in and work with the forms without a hassle. I respect your decision either way. I just wanted you to hear the perspective of a potential client. Thanks!

    Plugin Author Matthew Muro

    (@mmuro)

    Check out the vfb_override_email_ hooks. You’ll be able to custom code your own function to perform this kind of logic.

    We were hoping for a UI solution, not something we need to code. Thanks, anyway.

    Hi Matthew, may we know the feature (sending to different e-mails based on field entry) is available now? we would love to use this now. 🙂

    Currently, it’s not in VFB pro or regular except by custom programming …

    OR THROUGH A PLUGIN I WROTE: http://james.revillini.com/visual-form-builder-magic/

    This plugin gets installed ALONGSIDE VFB. It is not a replacement. Compatible with VFB 2.7.1.

    You can make the submitted info send to an email address specified in the form by adding the class “send-to” to the field while in the builder. Multiple emails are supported.

    This hasn’t been tested by anyone except me, so use at your own risk. Eventually I’ll post the link to the WordPress Plugin repository, but right now I’m just self-hosting.

    Plugin Author Matthew Muro

    (@mmuro)

    So this is how you use the vfb_override_email_ hook. This assumes your form ID is 114.

    add_action( 'vfb_override_email_114', 'vfb_action_override_email', 10, 5 );
    
    function vfb_action_override_email( $emails_to, $form_subject, $message, $headers, $attachments ){
        // Checks radio button. Use Merge Tag to easily get $_POST id
        if ( 'Marketing' == $_POST['vfb-10'] )
            $emails_to = array( 'test1@test.com', 'test2@test.com' );
        elseif ( 'HR' == $_POST['vfb-10'] )
            $emails_to = array( 'harry@test.com', 'sally@test.com' );
    
        // Send the mail
        foreach ( $emails_to as $email ) {
            wp_mail( $email, $form_subject, $message, $headers, $attachments );
        }
    }

    Of course, this is a basic implementation but that should give you some idea of how to use it. Hope that helps!

    That hook is only available in Pro or also in the free plugin?

    Plugin Author Matthew Muro

    (@mmuro)

    That hook is only in the Pro version.

    OK so just to clarify for all, Matt’s code example will only work in the Pro version, and in his example, he’s hard-coding form field id’s to do conditional logic and then emailing some hard-coded email addresses.

    My plugin, Visual Form Builder Magic, can be installed along with Matt’s Visual Form Builder and gives you the ability to “tag” certain fields in the form as “send to” addresses. The info submitted will go to them as well.

    Both approaches are valid and either could be better depending on what your needs are, and whether you have the Pro or free version.

    Plugin Author Matthew Muro

    (@mmuro)

    Hey jrevillini, cool stuff. I took a look at your code and you might want to update the switch to where it’ll work for other forms that aren’t an ID of 5.

    But yeah, anyone is free to use either method!

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘How do I send emails to different people based on field entry?’ is closed to new replies.