Guest User

Untitled

a guest
May 27th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Wrap hooks for a specific form.
  5. *
  6. * @param int $form_id
  7. */
  8. add_action( 'nf_get_form_id', function( $form_id ){
  9.  
  10. // Check for a specific Form ID.
  11. if( 21 !== $form_id ) return;
  12.  
  13. /**
  14. * Change a field's settings when localized to the page.
  15. * ninja_forms_localize_field_{$field_type}
  16. *
  17. * @param array $field [ id, settings => [ type, key, label, etc. ] ]
  18. * @return array $field
  19. */
  20. add_filter( 'ninja_forms_localize_field_checkbox', function( $field ){
  21.  
  22. if( 'checkbox_1527003278102' == $field[ 'settings' ][ 'key' ] ){
  23. // Change the `default_value` setting of the checkbox field.
  24. $field[ 'settings' ][ 'default_value' ] = 'checked';
  25. }
  26. return $field;
  27. });
  28. } );
Add Comment
Please, Sign In to add comment