1
votes

I am trying to do this:

Using Contact Form 7, I want to filter depending on a selectbox and send mail to one or other , I would do this sending with phpmail function...

So far I have this..

add_action( 'wpcf7_before_send_mail', 'process_form' );

function process_form( $cf7 ) {
 $submission = WPCF7_Submission::get_instance();

    if ( $submission ) {
        $posted_data = $submission->get_posted_data();
    }

    if( $cf7->id() == MYID ) {
    ... DO something
   }
}

And it works, it filters only when the ID of the form matches with MYID, but I want to return true or something and then show the normal message of "Your email has been sent" instead get stuck ont he loading gif. What kinda I do to get a "true" return or keep with the contact form 7 flow?

I obvioulsy tried with return true; At the "Do something" section I just send mail with mail(....")

1
you can't return data from add_action, you need to find a filter to do this with. If theres no filters effecting the info you want to change, you wont be able to modify the process.David

1 Answers

0
votes

I could fix this , after do the functions I had to, I only had to return it as simple as with a return

In order to send more mails and do more things I am using CF7 as well and sending new parameters on this way:

@wp_mail(....)

http://codex.wordpress.org/Function_Reference/wp_mail