• I’d like to show a specific form submission from a contact form 7 database using the shortcodes. However in the database view in the admin panel I do not see anything akin to an ID column that would allow me to filter / select only that particular form submission.

    Here’s a use case: We have a word press site for our elementary school. Parents / community members can post via a contact 7 form information that they would like posted to our website. This gets emailed for review to a short list of people. We are using the contact form 7 database extension to save the submission so ideally we don’t want to do double data entry to repost the information. It would be nice to create a new post that uses the short codes to extract the data from the database directly for the submission of interest. For example:

    [cfdb-html form="News and Events Submission Form" filelinks="link" filter="idColumn=submissionID"]
    ${your-subject}
    
    Posted by ${your-name} on ${Submitted}
    
    ${your-message}
    
    ${UploadSupportingPDF}
    
    <hr/>
    [/cfdb-html]
Viewing 7 replies - 1 through 7 (of 7 total)
  • 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.

    Thread Starter dmysticd

    (@dmysticd)

    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!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[contact form 7 database] ID for submission’ is closed to new replies.