• Resolved andrewg4u

    (@andrewg4u)


    Hello! I’ve seen some posts about conditional logic, and I know you can do a lot of this stuff in the hooks section, but figuring out the right code for what I want to do is the issue…

    I want to do something which is probably pretty simple. I basically want to do this:

    IF “field1” = “value1” THEN don’t send “field2”
    IF “field1” = “value2” THEN don’t send “field3”

    Or if it’s quicker to just say…
    IF “field2” is empty THEND don’t send it

    Any help is much appreciated! Thank you!

    https://www.ads-software.com/plugins/forms-3rdparty-integration/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author zaus

    (@zaus)

    Did you see the question right below yours?

    https://www.ads-software.com/support/topic/conditional-logic-feature?replies=6#post-6434793

    Please let me know if that answer was confusing.

    Thread Starter andrewg4u

    (@andrewg4u)

    Hi, thank you for the reply. Yes, I actually did see the post below mine and read through it, but it is still slightly confusing to me.

    I understand that the user was looking to use conditional logic to not send the results to the 3rd party if a certain condition was met… using the response_bypass. I just don’t know how to alter that code to make it work for my situation.

    I still want to post to the 3rd party, I just want to leave out specific fields.

    I’m sorry to take up your time with these simple questions. Thank you again for your time.

    Plugin Author zaus

    (@zaus)

    Ahhh…sorry, I didn’t read your question right.

    Your case would be easier — you just need to remove items from the post array before they get sent, no bypass necessary.

    Something like:

    add_filter('Forms3rdPartyIntegration_service_filter_post', 'forms3rdparty_conditional_send', 10, 3);
    
    function forms3rdparty_conditional_send($post, $service, $form) {
        // inspect transformed submission body for presence/lack/value of the desired value
        $field = 'my-conditional-field';
        if( isset($post[$field]) && $post[$field] == 'value-to-ignore') {
            // remove
            unset($post[$field]);
        }
        // return changed filter arg
        return $post;
    }

    (note the different hook)

    Thread Starter andrewg4u

    (@andrewg4u)

    Yes, this looks like exactly what I need. Thanks again for your help with this!

    Marking it as resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘More conditional logic…’ is closed to new replies.