antdigital
Forum Replies Created
-
Forum: Plugins
In reply to: [Contact Form DB] How to call submit_timeI think I should be clearer.
So I followed your guidance and this is my function codes
function testform($formData) { require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CF7DBPlugin.php'); // Change $formData if (!isset($posted_data['submit_time'])) { $plugin = new CF7DBPlugin(); $posted_data['submit_time'] = $plugin->generateSubmitTime(); } $formData->posted_data['email'] = $posted_data['submit_time']; return $formData; // be sure to return it } add_filter('cfdb_form_data', 'testform');and gotten this result (https://img42.com/j0pXe)
However as shown in the screenshot, I actually wanted the submit_time and field_value to have the same value (1476347176.3544 on both side instead of 1476347176.4563 on the field_value side).Forum: Plugins
In reply to: [Contact Form DB] How to call submit_timeHi Michael,
I took your advice to move my function, from my “/theme/functions.php” to <Add Shortcodes Actions And Filters> plugin.However I’ve not change the place I called the function, as on_sent_ok:”insert_submit_time_into_other_db($formData);” gave me an referenceerror (insert_submit_time_into_other_db is not defined).
I see the “lagged time” problem is caused by
if (!isset($posted_data['submit_time'])) { $plugin = new CF7DBPlugin(); $posted_data['submit_time'] = $plugin->generateSubmitTime(); }submit_time was not set and was generated again.
What could be the reason that $posted_data[‘submit_time’] is unable to get the submit_time in my function (on_sent_ok:”insert_submit_time_into_other_db($formData);)
Sorry for the troubles but thank you!
Forum: Plugins
In reply to: [Contact Form DB] How to call submit_timeHi Michael,
Thank you so much for the detailed guide, however the value still does not tally.
(eg. 1476261782.1369 in my function, but the actual submit_time is 1476261781.9349)Could the problem be in where I call the function.
///wp-content/plugins/contact-form-7/includes/submission.php private function submit() { if ( ! $this->is( 'init' ) ) { return $this->status; } $this->meta = array( 'remote_ip' => isset( $_SERVER['REMOTE_ADDR'] ) ? preg_replace( '/[^0-9a-f.:, ]/', '', $_SERVER['REMOTE_ADDR'] ) : '', 'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '', 'url' => preg_replace( '%(?<!:|/)/.*$%', '', untrailingslashit( home_url() ) ) . wpcf7_get_request_uri(), 'timestamp' => current_time( 'timestamp' ), 'unit_tag' => isset( $_POST['_wpcf7_unit_tag'] ) ? $_POST['_wpcf7_unit_tag'] : '' ); $contact_form = $this->contact_form; if ( ! $this->validate() ) { // Validation error occured $this->status = 'validation_failed'; $this->response = $contact_form->message( 'validation_error' ); } elseif ( ! $this->accepted() ) { // Not accepted terms $this->status = 'acceptance_missing'; $this->response = $contact_form->message( 'accept_terms' ); } elseif ( $this->spam() ) { // Spam! $this->status = 'spam'; $this->response = $contact_form->message( 'spam' ); } elseif ( $this->mail() ) { insert_submit_time_into_other_db($formData); //========!FUNCTION HERE!======== $this->status = 'mail_sent'; $this->response = $contact_form->message( 'mail_sent_ok' ); do_action( 'wpcf7_mail_sent', $contact_form ); } else { $this->status = 'mail_failed'; $this->response = $contact_form->message( 'mail_sent_ng' ); do_action( 'wpcf7_mail_failed', $contact_form ); } $this->remove_uploaded_files(); return $this->status; }- This reply was modified 9 years, 7 months ago by antdigital.
Forum: Plugins
In reply to: [Contact Form DB] How to call submit_timeI’m trying to call it when a submission comes in. Calling the function inside elseif ( $this->mail() ) { within the submit() .