cformsII Support Forum
Current User: Guest *Frequently Asked Questions*
Search 
Search Forums:


 




message counter - id

Add a New Topic Reply to Post
Post

tricky - Guest

11:09 pm - April 13, 2007

1

It'd be nice if there was some way to add a "counter" or unique id associated to a message.

 In case of registration forms for certain events, it can work as an automated registration syste, assigning each submission a registration number.


Congratulations on this, it really helps your blog improve user feedback-interaction 

Oliver - Admin

2:12 am - April 14, 2007

posts 3921

2

tricky,

If you turn on db tracking,  it will track all responses in a cforms WP table, with a unique  number (counter) associated. The number shown on the Tracking page is just a local counter showing the current # of save form submissions, but it's be easy to additionally show the actual message ID.

This however requires the db tracking feature to be turned on.

Would that do?


tricky - Guest

6:41 pm - April 17, 2007

3

Since it's a unique value, it will sure do. I wonder how can i output this number to the user, via mail or shown on the website.

Oliver - Admin

7:34 pm - April 17, 2007

posts 3921

4

Showing it online is not an option, since it'll be determined after the form is submitted and just before the email gets sent.

Take a look at cforms.php (line 470-480 & 953-960). After this line:

$wpdb->query(substr($sql,0,-1));

you could add:

$subID = $wpdb->get_row("select LAST_INSERT_ID() as number from $wpdb->cformsdata;");
$subID = $subID->number;

Then include the submission ID in the email, change (~508 &  +1045):

if ( $ccme )
    $sent = @mail($field_email, stripslashes($subject2), stripslashes($message), $headers2);
else
    $sent = @mail($field_email, stripslashes($subject2), stripslashes($message2), $headers2);

e.g., to: 

if ( $ccme )
    $sent = @mail($field_email, stripslashes($subject2).'(Submission ID:'.$subID.')', stripslashes($message), $headers2);
else
    $sent = @mail($field_email, stripslashes($subject2).'(Submission ID:'.$subID.')', stripslashes($message2), $headers2);

I tested this, it works and would be how I would solve it.

Of course you could also add the ID in the tracking report. In cforms-database.php, change line 190:

<li class="col0"><?php echo $i++; ?></li>

to:

<li class="col0"><?php echo $entry->id; ?></li>

This will replace the generic counter (always starting from 0) with the actual submission ID. 

tricky - Guest

8:07 pm - April 18, 2007

5

Thanks!

 

I'll try this 

Schmaart - Guest

11:18 am - November 10, 2008

6

I'm using a cformII as a petition and would like to display a counter on the page where the form resides to show people how many people have submitted so far and hence that they've made a difference by submitting!

In plain english I'm after some code to put above the form to show:

count wp_cformssubmissions where ID="1"

I think i'm along the right lines but my php skills are virtually non-existent.

Thanks in advance.

Schmaart - Guest

11:52 am - November 10, 2008

7

Thanks...I should have been more tenacious...the solution I think - for your other readers.

<?php
$sql = "SELECT count(id) FROM {$wpdb->cformssubmissions} WHERE form_id = 2";
$total = $wpdb->get_var($sql);
echo $total;
?>

Oliver - Admin

6:12 pm - November 10, 2008

posts 3921

8

...or you could have used the built-in function call:

get_cforms_submission_left(X);

with X being '' nothing or 2,3,4...

dopecoder - Guest

11:07 am - November 14, 2008

9

i would like to add the form unique id to the email send to the user after the form is submitted, i checked the reply above, however i cant seen to find that code in cforms.php, the reply was given in 2007, i guess the code has changed since than. is there a way i can achieve it now.


Thanks for the awesome form plugin btw

Oliver - Admin

10:08 am - November 16, 2008

posts 3921

10

you can, per the Help! page: {ID}

Reply to Post


Reply to Topic: message counter - id
PLEASE READ THE FAQs FIRST! THANK YOU.

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Topic Reply:

Save New PostSmileysOptions

Guest URL (required)

Math Required!
What is the sum of:
11 + 2
   

 
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell

Search