Grab values from the query string to fill in hidden fields in ninja forms [closed]

It looks like you can use the ninja_forms_display_init action to populate a field.

To get the job ID from the URL you mentioned above you can use the $_GET array.

Adapting the code from that documentation page, something like this should achieve what you’re looking for:

function wpse_158000_populate_field($form_id) {
    global $ninja_forms_loading;

    $job_id_field = 3; //put the id for your hidden field here

    //Change the value that a field is pre-populated with.
    $ninja_forms_loading->update_field_value($job_id_field, $_GET['jid']);
}

add_action('ninja_forms_display_init', 'wpse_158000_populate_field');

Their documentation lists a number of other actions you can tie into.

If you’re into using cleaner URLs you might want to hook into the rewrite_rules_array action and then you can have a URL more like http://www.example.com/apply/2 where 2 is the ID of the job they are applying for and apply is the slug of your apply page.

You could also push this farther and use the slug for that job instead of the ID for a nicer URL and then get the ID for that job via the slug and add that ID to your hidden field’s value.

tech