Skip to content

Instantly share code, notes, and snippets.

@kjohnson
Created May 22, 2018 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjohnson/d6b72578e2451adb13b3d50693f0a06c to your computer and use it in GitHub Desktop.
Save kjohnson/d6b72578e2451adb13b3d50693f0a06c to your computer and use it in GitHub Desktop.
<?php
/**
* Change a field's settings when localized to the page.
*
* @param array $field [ id, settings => [ type, key, label, etc. ] ]
* @return array $field
*/
add_filter( 'ninja_forms_localize_field', function( $field ){
if( 'my_field' == $field[ 'settings' ][ 'key' ] ) {
// Change the label setting of the field.
$field[ 'settings' ][ 'label' ] = 'New Field Label';
}
return $field;
});
<?php
/**
* Change a number field's settings when localized to the page.
*
* @param array $field [ id, settings => [ type, key, label, etc. ] ]
* @return array $field
*/
add_filter( 'ninja_forms_localize_field_number', function( $field ){
// Change the label setting of the field.
$field[ 'settings' ][ 'label' ] = 'New Number Field Label';
return $field;
});
<?php
/**
* Change a field's settings when localized to the page.
*
* @param array $field [ id, settings => [ type, key, label, etc. ] ]
* @return array $field
*/
add_filter( 'ninja_forms_localize_field', function( $field ){
// Change the label setting of the field.
$field[ 'settings' ][ 'label' ] = 'New Field Label';
return $field;
});
@stevegrunwell
Copy link

It appears that the dynamic-field-settings.php filter name should be ninja_forms_localize_fields (plural), not ninja_forms_localize_field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment