Where is Ninja form data stored in the WordPress database?

steva used Ask the Experts™
I have a Ninja form with textbox fields for user_firstname, user_lastname,  and website. When someone submits the form, where does the data go in the WordPress database?  Suppose, for example, I want to know the website for a given user_firstname and user_lastname. So I want something like:

sql = "SELECT 'website' from ??? WHERE user_firstname = 'John' AND user_lastname = 'Allen'";

What is the table I need to access?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
William NettmannPHP Web Developer

The data is stored in the wp_posts and wp_postmeta tables. You can see all the field values by doing this:
SELECT website from 

(SELECT m1.meta_value as user_firstname, m2.meta_value as user_lastname, m3.meta_value as website
 FROM dev_posts
 join dev_postmeta m1 on m1.post_id = ID and m1.meta_key = '_field_1'
 join dev_postmeta m2 on m2.post_id = ID and m2.meta_key = '_field_2'
 join dev_postmeta m3 on m3.post_id = ID and m3.meta_key = '_field_3'
 where post_type = 'nf_sub') as v1

WHERE user_firstname = 'John' AND user_lastname = 'Allen'

Open in new window

The "x" in "_field_x" is the field ID in Ninja Forms.


Thank you William for laying that out!  Did that come from any Ninja documentation you could point me to?  

Ninja makes it so easy to create a form but then they seem to go silent on how to get back the data you put into the form.  Do they expect us to write code like you've provided, or is there a simpler interface somewhere?

Thanks again for your help.
PHP Web Developer
Hi Steve,

No, that came from knowing how the WordPress database is laid out, and having a quick peek to see how Ninja is saving it's stuff. I suspect they may like you to purchase an extension or the pro version or something to easily access the data.

The submissions are custom posts, type "nf_sub" as you can see from the query.

All WordPress posts and pages are saved similarly, as is the data from many (not all) plugins.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial