I’ll push version 2.0.2 shortly in which you can use filter="submit_time=1308521822.8621"
for example to uniquely identify a submission.
Thanks!
I downloaded the latest version and see the submit_time feature.
Excuse me for re-opening this post…
I see the submit_time field but, how can i know it in the wpcf7_before_send_mail?
Obviously, I use cfdb plugin to store submissions into my db; I need also to assign a single submission to some wordpress users, so I need a unique field to use like a primary key.
Is the before_send_mail hook the right way? Any suggestion?
Thanks in advance and excuse my English! 🙂
Understand that the submit_time field is a key unique to each form submission. I infer that this does not meet your needs, but I don’t understand why.
Regarding the wpcf7_before_send_mail, the plugin registers a hook on that action. The result is that CF7 calls the CFDB hook passing it the form data. CFDB generates the submit_time key and stores the submission information in the database. It also stores the ID of the user if he is logged in. I don’t know if that answers your question.
Michael,
thanks for the response. I’ll try explain better…
I need to get submissions from anonymous users and assign them to some wordpress registered users; so I should store in a custom table a combination of (user_id – submission_id).
I think that the submit_time field should be great for the submission_id part, and that the wpcf7_before_send_mail hook is the right “place” to assign the submission to some users: my only problem is that i don’t know how/were to get the submit_time value in the hook!
This is my code:
add_action( 'wpcf7_before_send_mail', 'submission_to_user', 10);
function submission_to_user ( $f ) {
global $wpdb;
global $table_prefix;
// field ("1336380656.8600")
$submit_time = ''; // how to get this info??
$sql = "";
$usrs = $wpdb->get_results( "SELECT ... ;" );
if (0 == $wpdb->num_rows) {
// nobody
} else {
foreach ( $usrs as $usr ) {
if ("" != $sql) $sql .= ",";
$sql .= " (" . $usr->ID . ", " . $submit_time . ")";
}
$sql = 'INSERT INTO __________ (user_id, submission_id) VALUES' . $sql . ";";
}
if (false === $wpdb->query( $wpdb->prepare($sql) )) {
// ERROR
} else {
// OK
}
}
There isn’t a good way to do this. So I put in a filter that you can use to get a handle to the data that is going into the DB including the submit time.
I’ll probably push this in the 2.4 version later today or tomorrow.
I documented that here: http://cfdbplugin.com/?page_id=747
Michael you are great!
To be sure that data are in the db before I assign to users, I still use the wpcf7_before_send_mail, but now thanks to you I can get the submit_time value!
add_action( 'wpcf7_before_send_mail', 'submission_to_user', 10);
function submission_to_user ( $f ) {
// ... ...
$submit_time = $f->submit_time;
// ... ...
}
Thanks a lot!