Hi, I’m struggling with this as well.
I have a checkbox called “newsletteroptin” and if someone ticks it when filling form I want it to post the form data to my 3rd party form.
I have it working without the hook, and have tried implementing the hook from replies to other posts but can’t get it working. Help would be appreciated.
Thanks,
Dan
Plugin Author
zaus
(@zaus)
Did you see my correction — the hook should instead return something like $post_args['response_bypass'] = array('body' => 'OKAY', 'response' => array('code' => 200));
Can you paste the debug email here?
Thread Starter
phxt
(@phxt)
What I’ve got is:
add_filter('Forms3rdPartyIntegration_service_filter_args', 'forms3rdparty_conditional_send', 10, 3);
function forms3rdparty_conditional_send($post_args, $service, $form) {
if( !isset($post_args['body']['subscribe']) ) {
$post_args['response_bypass'] = array('body' => 'OKAY', 'response' => array('code' => 200));
}
return $post_args;
}
but this just stops the form from sending data to the 3rd party altogether, whether or not the “Subscribe” box is checked.
Thread Starter
phxt
(@phxt)
The response email I get when the “Subscribe” box is checked is:
*** Service ***
Array
(
[name] => Mail Subscribe
[url] => http://xxx.com/signup.ashx
[forms] => Array
(
[0] => cf7_172
)
[success] =>
[failure] =>
[timeout] => 10
[hook] => true
[mapping] => Array
(
[0] => Array
(
[lbl] => The email address
[src] => your-email
[3rd] => email
)
[1] => Array
(
[val] => 1
[lbl] => List
[src] => 012461072
[3rd] => addressbookid
)
[2] => Array
(
[val] => 1
[lbl] => User ID
[src] => 012120946
[3rd] => userid
)
)
[separator] => ,
)
*** Post (Form) ***
http://xxx.com/contact-us/
Array
(
[_wpcf7] => 172
[_wpcf7_version] => 4.0.1
[_wpcf7_locale] => en_US
[_wpcf7_unit_tag] => wpcf7-f172-o1
[_wpnonce] => 29127125db
[your-name] => Test
[your-email] => test5@xxx.com
[menu-633] => Hotel
[tel-836] => 0123456789
[your-subject] => Test
[your-message] => Test
[subscribe] => subscribe
[_wpcf7_is_ajax_call] => 1
)
*** Post (to Service) ***
Array
(
[timeout] => 10
[body] => Array
(
[email] => test5@xxx.com
[addressbookid] => 012461072
[userid] => 012120946
)
[response_bypass] => Array
(
[body] => OKAY
[response] => Array
(
[code] => 200
)
)
)
*** Response ***
Array
(
[body] => OKAY
[response] => Array
(
[code] => 200
)
)
Plugin Author
zaus
(@zaus)
@phxt You didn’t map the subscribe field, so it’s never getting passed to the hook. You can see this by comparing the “Post (Form)” section, which has subscribe, to the “Post (Service)” section, which does not. Since your hook will set the bypass when subscribe isn’t there, it’s never making the remote post as you pointed out.
Thread Starter
phxt
(@phxt)
Ah, thank you. Works perfectly now.