Description
Modify the settings used to import a form from an XML export file. Useful when adding your own field types with custom settings stored as an array.
Usage
add_filter( 'gform_import_form_xml_options', 'my_custom_function' );
Parameters
Parameter | Type | Description |
---|---|---|
$options | array | Array of options for the XML import. |
Examples
In this example we demonstrate how to specify that a custom form setting should be unserialized as an array (rather than an object). This assumes that the setting is created in an array format. When the form is exported to XML it will no longer be in array format so on import we need to specify how it should be formatted.
add_filter( 'gform_import_form_xml_options', 'my_custom_import_xml_options' );
function my_custom_import_xml_options( $options ) {
$options['my_custom_form_setting'] = array( 'unserialize_as_array' => true );
return $options;
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
This filter is located in GFExport::import_xml() in export.php.