Last active
May 22, 2018 15:15
-
-
Save kjohnson/cbd382a1014b8b3cc4cf8ab92e867011 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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( 19 !== $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_number', function( $field ){ | |
if( 'number_1527000740297' !== $field[ 'settings' ][ 'key' ] ) return $field; | |
// Check for a `min` value as a querystring. ex site.com/?min=12 | |
if( ! isset( $_GET[ 'min' ] ) ) return $field; | |
// Change the `min` setting of the number field. | |
$field[ 'settings' ][ 'num_min' ] = intval( $_GET[ 'min' ] ); | |
return $field; | |
}); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 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_number', function( $field ){ | |
// Change the `min` setting of the number field. | |
$field[ 'settings' ][ 'num_min' ] = 12; | |
return $field; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment