Skip to content Skip to sidebar
availability:

WPML Version: 4.9.2

description:

Use this filter when you need to modify the contents of the configuration in wpml-forms-config.xml in a way that is safe from updates, or when you’re developing a plugin/theme that requires this.

$config is created based on wpml-forms-config.xml and can have a complex structure, so it’s best to first make changes in wpml-forms-config.xml, then preview it and reconstruct the array structure for the modification you’re interested in — see the example in Hook usage.

Note: This filter is available in Ninja Forms ML 0.5.0 and later.

type:
filter
category:
Miscellaneous
parameters:

apply_filters( “wpml_forms_config_ninja-forms”, array $config );

$config
– (array)(Required) The configuration defined in wpml-forms-config.xml for this plugin, converted into an array format.

hook example usage:

add_filter( 'wpml_forms_config_ninja-forms', function ( array $config ): array {
    $config['field']['my-custom-field'] = [
        'type'       => 'ARRAY',
        'properties' => 'f_label'
    ];
    return $config;
} );

/**
 * Developer Example
 *
 * How to persist the change in the simplest way:
 * 1. Modify the `wpml-forms-config.xml` file as needed to achieve the desired effect.
 * 2. Run the filter and execute `var_export( $config );`
 *    - then locate the modified elements and apply them manually to `$config`.
 *    - After that, you can restore the original `wpml-forms-config.xml` file
 *    - verify that everything behaves correctly.
 */
add_filter( 'wpml_forms_config_ninja-forms', function ( array $config ): array {
    // add modifications here
    var_export( $config );
    return $config;
} );