[Plugin: Contact Form 7] Special tags not sent to wpcf7_before_send_mail for saving to MySQL?
-
It seems wpcf7_before_send_mail doesn’t get sent the special tags?
Am using the below code to save form data to MySQL, and only the name & email entries are stored in the database; the extended tags (site name & url, ip, etc.) are null.
/* TBD save application data back to database */ function save_application_form( $cf7 ) { // form data $SITENAME = $cf7->posted_data["_post_title"]; $SITEURL = $cf7->posted_data["_post_url"]; $NAMEFIRST = $cf7->posted_data["applicant-name-first"]; $NAMEFAMILY = $cf7->posted_data["applicant-name-family"]; $EMAIL = $cf7->posted_data["applicant-email"]; // additional data $IPADDRESS = $cf7->posted_data["_remote_ip"]; $DATEAPPLY = $cf7->posted_data["_date"]; $TIMEAPPLY = $cf7->posted_data["_time"]; $sql = "INSERT INTO somedbase.sometable ( application_ID, site_name, site_url, applicant_name_first, applicant_name_family, applicant_email, applicant_ip_address, applicant_date_apply, applicant_time_apply ) VALUES ( 'NULL', '$SITENAME', '$SITEURL', '$NAMEFIRST', '$NAMEFAMILY', '$EMAIL', '$IPADDRESS', '$DATEAPPLY', '$TIMEAPPLY' );"; mysql_query($sql); } add_action( 'wpcf7_before_send_mail', 'save_application_form' );
[adding: for those looking for a simple way to save CF7 form data to MySQL, the above code works. You’ll want to replace somedbase & sometable with your site’s mysql info, next add sometable to your database (with the desired keys structure), then just add the above code to functions.php! Enjoy!]
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘[Plugin: Contact Form 7] Special tags not sent to wpcf7_before_send_mail for saving to MySQL?’ is closed to new replies.