Displaying the total number of submissions in a specific Ninja Form

46 Views Asked by At

Ive been trying to figure out how i would display the total number of submissions for a specific form of Ninja Forms on a separate page on my website.

I have a client that i created a form for that gets thousands of submissions daily, and keeps asking me what the total number of submissions are, i would like to display it on a separate hidden page for them, so they can check themselves instead of asking me every few hours.

Please help if this is possible?

Thank you so much!

1

There are 1 best solutions below

0
Ryan On

So managed to figure this out. If anyone needs to also do this here is the code to create a shortcode in your functions.php file to display the total submissions of a form on the front-end.

function nf_submission_count_shortcode() {
global $wpdb;
$form_id = '5'; // Replace YOUR_FORM_ID with the actual form ID
$table_name = $wpdb->prefix . 'nf3_forms';
$query = $wpdb->prepare("SELECT seq_num FROM $table_name WHERE id = %d", $form_id);
$submission_count = $wpdb->get_var($query);

return "Total Submissions: " . $submission_count;}

add_shortcode('nf_submission_count', 'nf_submission_count_shortcode');

Then use the shortcode anywhere:

[nf_submission_count]