Skip to content

Instantly share code, notes, and snippets.

@Deaner666
Last active August 29, 2015 14:21
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 Deaner666/4dd5c87a9a98d8522628 to your computer and use it in GitHub Desktop.
Save Deaner666/4dd5c87a9a98d8522628 to your computer and use it in GitHub Desktop.
Pre-populate a Ninja Forms Tier field from a URL parameter
<?php
add_filter( 'ninja_forms_field', 'wpm_handle_http_query_string' );
function wpm_handle_http_query_string( $data ) {
if($data['label']=='Tier' && get_query_var('tier')) {
foreach ($data['list']['options'] as $key => $value) {
if($value['value'] == get_query_var('tier')) {
$data['list']['options'][$key]['selected'] = 1;
}
}
}
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment