Code Monkey home page Code Monkey logo

forms-3rdparty-inject-results's Introduction

=== Forms: 3rd-Party Inject Results ===
Contributors: zaus
Donate link: http://drzaus.com/donate
Tags: contact form, form, CRM, mapping, 3rd-party service, services, remote request, forms-3rdparty, inject response, inject results
Requires at least: 3.0
Tested up to: 5.2.2
Stable tag: trunk
License: GPLv2 or later

Injects the response from a Forms: 3rdparty submission into the original contact form.

== Description ==

Allows you to include results from a [Forms 3rdparty Integration](http://wordpress.org/plugins/forms-3rdparty-integration/) submission by flattening the response and inserting it within the original contact form submission.

== Installation ==

1. Unzip, upload plugin folder to your plugins directory (`/wp-content/plugins/`)
2. Make sure [Forms 3rdparty Integration](http://wordpress.org/plugins/forms-3rdparty-integration/) is installed and settings have been saved at least once.
3. Activate plugin
4. In the newly available section "Inject Results" in the '3rdparty services' admin, enter the flattened service response keys like `Response/Body/SomeKey`, one per line.
	a. If the response is JSON or XML it will scan the elements/keys according to the segments you've entered; in the above example it will look for `{ Response: { Body: { SomeKey: "foobar" } } }` and include "foobar" with the submission.
5. Some contact form plugins only allow injecting/overwriting an existing field (e.g. Gravity Forms).  In these cases you can provide an "alias" to overwrite with `Response/Body/SomeKey=the_alias`, where _the_alias_ is the contact form field to override.
	a. With Gravity Forms, fields should be overwritten using aliases like `input_X` where 'X' is the field's id.


== Frequently Asked Questions ==

= How does it add the response values? =

If you have an endpoint [test-response.php](http://yoursite.com/plugins/forms-3rdparty-inject-results/test-response.php) that will "echo" back your 3rdparty submission with keys altered to be prefixed with 'req-', then if your submission was

	{ name: { first: "FirstName", last: "LastName" }, email: "[email protected]", etc: "foobar" }

The response would be flattened and prefixed to

	{ "req-name/first": "FirstName", "req-name/last": "LastName", "req-email": "[email protected]", "req-etc": "foobar" }

You would then inject `req-name/first` or `req-etc`.

= What are some XML/JSON examples? =

*XML*

	[env:Envelope/env:Body/ns1:Response/ns1:Resultstatus] => foo
	[env:Envelope/env:Body/ns1:Response/ns1:Result] => bar
	[env:Envelope/env:Body/ns1:Response/ns1:Description] => baz

*JSON*

	[Body/Response/ResultStatus] => foo
	[Body/Response/Result] => bar
	[Body/Response/Description] => baz

	
Note that XML responses will include the namespace prefixes.  You may then reference them by the entire key shown above.

= It doesn't work right... =

Drop an issue at https://github.com/zaus/forms-3rdparty-inject-results

== Screenshots ==

N/A.

== Changelog ==

= 0.3 =
* fix: inconsistent nested key delimiters, now expecting '/'
* removed testing endpoint per WP Security request (see archives for example)

= 0.2 =
* confirmed with GF at least

= 0.1 =

IT HAS BEGUN

== Upgrade Notice ==

= 0.3 =
Delimiter format handling has changed.  May be a breaking change if you were using it "wrong" (according to how it was previously described).

forms-3rdparty-inject-results's People

Contributors

zaus avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

forms-3rdparty-inject-results's Issues

Conflict with forms-3rdparty-postagain

When used in conjunction with zaus/forms-3rdparty-postagain the secondary post resolves before the original post does. If the injection is in both services, it will correctly inject into Gravity Forms (via updating the $_POST var) in the secondary post but when the original post resolves it reapplies the "original" submission values (which won't include the latest injection) overwriting what it had just changed. Use of the array union operator + exacerbates the problem because it will replace a non-empty value with an empty value for the same key.

Might want an "overwrite" setting for the plugin? Specifically because GF would typically inject into an empty, hidden field.

log example of overwrite bug / plugin conflict

// this is the postagain 2ndary service --
29-Mar-2017 05:03:09 UTC] Array
(
    [0] => Forms3rdpartyIntegration_Gf
    [1] => INJECT
    [2] => Array
        (
            [oldPOST] => Array
                (
                    [input_1] => Tester5 Testington5
                    [input_2] => Second Choice
                    [input_3] => [email protected]
                    [MAX_FILE_SIZE] => 2097152
                    [input_5] => testing secondary post + inject
                    [input_6] => 
                    [input_7] => 
                    [is_submit_1] => 1
                    [gform_submit] => 1
                    [gform_unique_id] => 
                    [state_1] => WyJbXSIsIjE3MzZjMDM5Nzc1NTc3ZmI5MGIxM2E5MmM5N2QxM2IyIl0=
                    [gform_target_page_number_1] => 0
                    [gform_source_page_number_1] => 1
                    [gform_field_values] => 
                )

        )

)

[29-Mar-2017 05:03:09 UTC] Array
(
    [0] => Forms3rdpartyIntegration_Gf
    [1] => INJECT
    [2] => Array
        (
            [newPOST] => Array
                (
                    [input_7] => ABCDSecond ChoiceEFGH
                    [input_1] => Tester5 Testington5
                    [input_2] => Second Choice
                    [input_3] => [email protected]
                    [MAX_FILE_SIZE] => 2097152
                    [input_5] => testing secondary post + inject
                    [input_6] => 
                    [is_submit_1] => 1
                    [gform_submit] => 1
                    [gform_unique_id] => 
                    [state_1] => WyJbXSIsIjE3MzZjMDM5Nzc1NTc3ZmI5MGIxM2E5MmM5N2QxM2IyIl0=
                    [gform_target_page_number_1] => 0
                    [gform_source_page_number_1] => 1
                    [gform_field_values] => 
                    [Name] => Tester5 Testington5
                    [Options] => Second Choice
                    [Email] => [email protected]
                    [Message] => testing secondary post + inject
                    [Response Name] => 
                    [Another Response] => 
                    [input_4_attach] => http://sandbox.wp/wp-content/uploads/gravity_forms/1-335288f34d4612173e2290cdfffab314/tmp/58db400d46c2f_input_4.docx
                    [input_4_size] => 28
                    [input_4_mime] => 
                    [input_4] => test-resume.docx
                )

            [newfields] => Array
                (
                    [input_7] => ABCDSecond ChoiceEFGH
                    [input_1] => Tester5 Testington5
                    [input_2] => Second Choice
                    [input_3] => [email protected]
                    [MAX_FILE_SIZE] => 2097152
                    [input_5] => testing secondary post + inject
                    [input_6] => 
                    [is_submit_1] => 1
                    [gform_submit] => 1
                    [gform_unique_id] => 
                    [state_1] => WyJbXSIsIjE3MzZjMDM5Nzc1NTc3ZmI5MGIxM2E5MmM5N2QxM2IyIl0=
                    [gform_target_page_number_1] => 0
                    [gform_source_page_number_1] => 1
                    [gform_field_values] => 
                    [Name] => Tester5 Testington5
                    [Options] => Second Choice
                    [Email] => [email protected]
                    [Message] => testing secondary post + inject
                    [Response Name] => 
                    [Another Response] => 
                    [input_4_attach] => http://sandbox.wp/wp-content/uploads/gravity_forms/1-335288f34d4612173e2290cdfffab314/tmp/58db400d46c2f_input_4.docx
                    [input_4_size] => 28
                    [input_4_mime] => 
                    [input_4] => test-resume.docx
                )

        )

)

// this is the original service --
[29-Mar-2017 05:03:09 UTC] Array
(
    [0] => Forms3rdpartyIntegration_Gf
    [1] => INJECT
    [2] => Array
        (
            [oldPOST] => Array
                (
                    [input_7] => ABCDSecond ChoiceEFGH
                    [input_1] => Tester5 Testington5
                    [input_2] => Second Choice
                    [input_3] => [email protected]
                    [MAX_FILE_SIZE] => 2097152
                    [input_5] => testing secondary post + inject
                    [input_6] => 
                    [is_submit_1] => 1
                    [gform_submit] => 1
                    [gform_unique_id] => 
                    [state_1] => WyJbXSIsIjE3MzZjMDM5Nzc1NTc3ZmI5MGIxM2E5MmM5N2QxM2IyIl0=
                    [gform_target_page_number_1] => 0
                    [gform_source_page_number_1] => 1
                    [gform_field_values] => 
                    [Name] => Tester5 Testington5
                    [Options] => Second Choice
                    [Email] => [email protected]
                    [Message] => testing secondary post + inject
                    [Response Name] => 
                    [Another Response] => 
                    [input_4_attach] => http://sandbox.wp/wp-content/uploads/gravity_forms/1-335288f34d4612173e2290cdfffab314/tmp/58db400d46c2f_input_4.docx
                    [input_4_size] => 28
                    [input_4_mime] => 
                    [input_4] => test-resume.docx
                )

        )

)

[29-Mar-2017 05:03:09 UTC] Array
(
    [0] => Forms3rdpartyIntegration_Gf
    [1] => INJECT
    [2] => Array
        (
            [newPOST] => Array
                (
                    [input_6] => 1234Tester5 Testington54321
                    [req-femail] => [email protected]
                    [input_1] => Tester5 Testington5
                    [input_2] => Second Choice
                    [input_3] => [email protected]
                    [MAX_FILE_SIZE] => 2097152
                    [input_5] => testing secondary post + inject
                    [input_7] => 
                    [is_submit_1] => 1
                    [gform_submit] => 1
                    [gform_unique_id] => 
                    [state_1] => WyJbXSIsIjE3MzZjMDM5Nzc1NTc3ZmI5MGIxM2E5MmM5N2QxM2IyIl0=
                    [gform_target_page_number_1] => 0
                    [gform_source_page_number_1] => 1
                    [gform_field_values] => 
                    [Name] => Tester5 Testington5
                    [Options] => Second Choice
                    [Email] => [email protected]
                    [Message] => testing secondary post + inject
                    [Response Name] => 
                    [Another Response] => 
                    [input_4_attach] => http://sandbox.wp/wp-content/uploads/gravity_forms/1-335288f34d4612173e2290cdfffab314/tmp/58db400d46c2f_input_4.docx
                    [input_4_size] => 28
                    [input_4_mime] => 
                    [input_4] => test-resume.docx
                )

            [newfields] => Array
                (
                    [input_6] => 1234Tester5 Testington54321
                    [req-femail] => [email protected]
                    [input_1] => Tester5 Testington5
                    [input_2] => Second Choice
                    [input_3] => [email protected]
                    [MAX_FILE_SIZE] => 2097152
                    [input_5] => testing secondary post + inject
                    [input_7] => 
                    [is_submit_1] => 1
                    [gform_submit] => 1
                    [gform_unique_id] => 
                    [state_1] => WyJbXSIsIjE3MzZjMDM5Nzc1NTc3ZmI5MGIxM2E5MmM5N2QxM2IyIl0=
                    [gform_target_page_number_1] => 0
                    [gform_source_page_number_1] => 1
                    [gform_field_values] => 
                    [Name] => Tester5 Testington5
                    [Options] => Second Choice
                    [Email] => [email protected]
                    [Message] => testing secondary post + inject
                    [Response Name] => 
                    [Another Response] => 
                    [input_4_attach] => http://sandbox.wp/wp-content/uploads/gravity_forms/1-335288f34d4612173e2290cdfffab314/tmp/58db400d46c2f_input_4.docx
                    [input_4_size] => 28
                    [input_4_mime] => 
                    [input_4] => test-resume.docx
                )

        )

)

Correct Syntax/Format to Retrieve <zestimate> field contents

I have spent the entire day attempting to capture and display the contents from an API call to Zillow into the form from which it was submitted. I finally successfully connected to Zillow, receiving the response contained in file:

forms-3rd-party-debug-response.txt

The successful Zillow XML response, along with the field(s) I need to capture can be seen in the attached file:

zillow_xml_response.txt

Correct syntax/formatting information is scarce on this topic. Your assistance would be greatly appreciated.

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.