Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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

This comment has been minimized.

Copy link

@stevegrunwell stevegrunwell commented Jul 22, 2019

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