How to access Ninja Forms user submitted values in WP

user3491779 picture user3491779 · Oct 25, 2015 · Viewed 12.6k times · Source

My client's WordPress site uses the Ninja Forms plugin for forms. There's a web page with a form that's set up to redirect to another page. I need to access the submitted form data from the redirect page, but the form values don't show up in a $_POST array on the redirect page.

Here's a Ninja Forms support page that I think provides instructions on how to achieve what I'm describing, but it's a bit over my head:

http://docs.ninjaforms.com/customer/portal/articles/1981023-processing-ninja_forms_processing

Do I need to add PHP to the form page? To the redirect page? To both?

I'd be grateful if someone who understands this page would have a look and tell me what I need to do to access the submitted form values from the redirect page.

Answer

Gul Muhammad picture Gul Muhammad · Nov 23, 2015

If you want to access the values submitted/entered in the form fields on redirected page you can use [ninja_forms_all_fields].

It will out put all fields values there or if you want to show a specific field value you can use [ninja_forms_field id=93]. 93 can be the ID of any field you want to access.

If you have a template page in your theme you can write a function in your functions.php and can write what ever code you want.

To write a function there where you must have to put the global variable $ninja_forms_processing there. Then to access a field you can write the following code:

 $value2 = $ninja_forms_processing->get_field_value( 152 );

In the documentation of Ninja Forms they have clearly mentioned not to use $_POST[].

It is the main function for interacting with both user submitted values and stored form data. Developers should use this instead of simply trying to access $_POST or $_REQUEST data. It has already been sanitized and values can be modified for use in other hooked functions.