Closed Shtarley closed 7 years ago
Use hook number 4 from https://wordpress.org/plugins/forms-3rdparty-integration/other_notes/ and filter the $post array, then return it.
The code should go in your theme functions file or a plugin.
Thank you for your willingness to help me - I'm afraid I will need a little bit more information though... I have extremely basic php knowledge, I get the concept of wordpress hooks.... however, I don't really understand how to do what I need to get done.
You're saying, I should use the following hook:
add_filter('Forms3rdPartyIntegration_service_filter_post', 'YOUR_HOOK', 10, 4);
I'm assuming I will start with something like this:
add_filter('Forms3rdPartyIntegration_service_filter_post_0', 'skip_empty_fields', 10, 4);
and then create a function to skip empty fields? I don't know how to create a function to check all fields, and then to skip sending fields that have no value, to the third party.
Can you please help me a littler further? The plugin has been absolutely amazing so far, I just need this one last thing to get it to work. The third party rejects the submission when the plugin tries to send fields to them that have been left empty... (these are conditional gravity form fields, so I can't force users to enter something into those fields by simply making them required fields). I need the plugin to just not try to send empty fields inside the form.
You probably don't need the formid suffix (_filter_post_0
) -- it just means it'll work for form 0.
add_filter('Forms3rdPartyIntegration_service_filter_post', 'shtarley_empty_removal', 10, 4);
function shtarley_empty_removal($post, $service, $form, $sid) {
// loop through $post to remove empties
foreach($post as $key => $value)
if(empty($value))
unset($post[$key]);
// return what you want to submit
return $post;
}
I'm assuming this worked...
First of all… thank you so much for this amazing plugin… so far it has worked extremely well for me. I just have one issue…. The third party rejects the submission if some of the fields are empty. I need a way for the plugin to skip sending empty fields to the third party…
I tried the codes on this page: https://wordpress.org/plugins/forms-3rdparty-integration/faq/ But I don’t think I’m using it correctly. My form’s mapping has already been done, so I tried to use the code right at the bottom of that page (and added it to my funtions.php), but then my site went blank, so I removed the code again. Am I suppose to modify the code or something?
FYI, I'm using gravity forms.