Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Wrap hooks for a specific form.
- *
- * @param int $form_id
- */
- add_action( 'nf_get_form_id', function( $form_id ){
- // Check for a specific Form ID.
- if( 21 !== $form_id ) return;
- /**
- * Change a field's settings when localized to the page.
- * ninja_forms_localize_field_{$field_type}
- *
- * @param array $field [ id, settings => [ type, key, label, etc. ] ]
- * @return array $field
- */
- add_filter( 'ninja_forms_localize_field_checkbox', function( $field ){
- if( 'checkbox_1527003278102' == $field[ 'settings' ][ 'key' ] ){
- // Change the `default_value` setting of the checkbox field.
- $field[ 'settings' ][ 'default_value' ] = 'checked';
- }
- return $field;
- });
- } );
Add Comment
Please, Sign In to add comment