Contributors: zaus, leadlogic
Donate link: http://drzaus.com/donate
Tags: contact form, form, contact form 7, CF7, gravity forms, GF, CRM, mapping, 3rd-party service, services, remote request, xml, json, soap, xml webservice, soap webservice, json webservice, nested fields, xpost
Requires at least: 3.0
Tested up to: 4.9.6
Stable tag: trunk
License: GPLv2 or later
Converts submission from Forms 3rdparty Integration to xml/json, add headers, or nest fields.
Converts external submission from Forms: 3rdparty Integration plugin to XML or JSON post; optionally can add custom headers (to allow SOAP submissions) or transform/combine separate fields into nested values.
This plugin will turn the 3rdparty mappings into XML elements, so that each form post will be the value (or attribute) of an XML element.
/wp-content/plugins/
)/
, and indicate attributes with @
. Numeric indexes by themselves will result in repetition of the parent element (ex. item/%i/sub
could make <item><sub /></item><item><sub /></item>
).Submit an issue to the GitHub issue tracker in addition to / instead of the WP Support Forums.
See "base plugin" Forms: 3rdparty Integration.
Provide the list of headers as though they were a URL querystring, so that
Content-Type: something X-Special-Header: something-else
would be given as
Content-Type=something&X-Special-Header=something-else
You may also use shortcodes such as base64
in the header.
Separate element names within the same 3rdparty field mapping using /
, so that in order to make:
<credentials type="123">
<user>xyz</user>
<pass>abc</pass>
</credentials>
you would use credentials/@type
, credentials/user
and credentials/pass
, respectively.
Note: You may nest and wrap elements even if not transforming into XML; they will be submitted as multi-dimensional arrays like:
credentials[@type]=123&credentials[user]=xyz&credentials[pass]=abc
As of v1.3, if there is a standalone numerical index it will cause repetition of the "parent" element.
ex) If the post is:
item => array (
0 => value1,
1 => value2,
2 => value3
)
it will result in
<item>value1</item>
<item>value2</item>
<item>value3</item>
You can accomplish this with the Forms-3rdparty separator [%]
to place your index appropriately.
Just enter the entire root xml in the field, a la http://stackoverflow.com/questions/5992268/simplexml-how-to-correctly-set-encoding-and-xmins
To produce <SomeTag />
, make sure the "Autoclose" option is enabled.
To produce <SomeTag></SomeTag>
, make sure the "Autoclose" option is unchecked.
Use the 'Mask' format, which allows you to specify the result exactly as you want via string replacement (sprintf
), or the 'Replace'/'Advanced Replace' format which will replace string tokens ({{3rdparty}}
). Useful for complex XML.
sprintf
for "Mask" or str_replace
for "Replace"), so make sure to include the post body with the appropriate placeholder(s) (%s
for "Mask", {{3rdparty_Fields}}
for "Replace").%s
to indicate where the submission value should go.[xpost-loop on="repeatingFieldKey" times="a number"]loop content[/xpost-loop]
will repeat the loop content
either times or for each key in the array repeatingFieldKey (which is your 3rdparty mapped field)myfield1
, myfield2
, etc)For the given mapping:
Source 3rdparty
------ --------
input_1 name
input_2 phone
input_3.1 files\%i\name
input_3.2 files\%i\name
input_3.3 files\%i\name
input_4.1 files\%i\content
input_4.2 files\%i\content
input_4.3 files\%i\content
input_5.1 files\%i\mime
input_5.2 files\%i\mime
input_5.3 files\%i\mime
Normally the input_3.*
fields would get grouped together, as would the input_4.*
fields. Using separator [%]
, it will create a nested list like:
array(
'files' => array(
0 => array(
'name' => 'value of input_3.1',
'mime' => 'value of input_5.1',
'content' => 'value of input_4.1' ),
1 => array(
'name' => 'value of input_3.2',
'mime' => 'value of input_5.2',
'content' => 'value of input_4.2' ),
2 => array(
'name' => 'value of input_3.3',
'mime' => 'value of input_5.2',
'content' => 'value of input_4.3' ),
))
With Advanced Replacement, you could set the "Root Elements" field to something like the following (which mimics a normal form upload):
--multipartboundaryPE6azq
Content-Disposition: form-data; name="myNameField"
{{name}}
--multipartboundaryPE6azq
Content-Disposition: form-data; name="myPhoneField"
{{phone}}
[xpost-loop on="files"]--multipartboundaryPE6azq
Content-Disposition: form-data; name="myUploadFiles"; filename="{{name}}"
Content-Type: {{mime}}
{{content}}
[/xpost-loop]
Note the use of the shortcode xpost-loop
which will repeat for each of the elements in the nested files
array, replacing the placeholders accordingly.
None available.
xpost-loop
shortcode{{3rdparty}}
multipart/form-data
and 'url' formatting per GitHub issue #6 https://github.com/zaus/forms-3rdparty-xpost/issues/6Can post body as json instead
Fixed GitHub issue #3 https://github.com/zaus/forms-3rdparty-xpost/issues/3:
post
wrapper unless sending as xml (and if you send XML you should specify a wrapper)Can nest regular post fields even when not submitting XML.
SimpleXMLElement
Base version - xml and header transformation
n
item/%i/sub%i
could make <item><sub1 /></item><item><sub2 /></item>