1
請通過下面的代碼,我試圖將我的聯繫表7數據插入我的mysql表(即wp_tps_forms)。 在這種情況下,我複製下面的代碼粘貼在我主題的functions.php文件中,但它不起作用。如何在wordpress中插入聯繫表7數據到mysql數據庫
add_action('wpcf7_before_send_mail', 'save_form');
function save_form($wpcf7)
{
global $wpdb;
$title = $wpcf7->title();
$company_name=$wpcf7->posted_data["company-name"];
$email=$wpcf7->posted_data["your-email"];
$start_year=$wpcf7->posted_data["start-year"];
$team=$wpcf7->posted_data["team"];
$business_model=$wpcf7->posted_data["business-model"];
$sub_category_business=$wpcf7->posted_data["sub-category-business"];
$competition=$wpcf7->posted_data["competition"];
$phase_of_business=$wpcf7->posted_data["phase-of-business"];
$stage_of_product=$wpcf7->posted_data["stage-of-product"];
$customer_traction=$wpcf7->posted_data["customer-traction"];
$estimate_funding=$wpcf7->posted_data["estimate-funding"];
$website_url=$wpcf7->posted_data["website-url"];
$contact_number=$wpcf7->posted_data["contact-number"];
$what_does_your_company_do=$wpcf7->posted_data["what-does-your-company-do"];
$core_team=$wpcf7->posted_data["core-team"];
$what_is_unique_selling_point=$wpcf7->posted_data["what-is-unique-selling-point"];
$go_to_market=$wpcf7->posted_data["go-to-market"];
$any_other_information=$wpcf7->posted_data["any-other-information"];
$link_to_url=$wpcf7->posted_data["link-to-url"];
$file=$wpcf7->posted_data["file-01"];
$wpdb->insert($wpdb->prefix . 'tps_forms',
array('id' => '','form' => $submited['title'],'company-name'=> '$company_name','your-email' => '$email','start-year' => '$start_year','team' => '$team','business-model' => '$business_model','sub-category-business' => '$sub_category_business','competition' => '$competition','phase-of-business' => '$phase_of_business','stage-of-product' => '$stage_of_product','customer-traction' => '$customer_traction','estimate-funding' => '$estimate_funding','website-url' => '$website_url','contact-number' => '$contact_number','what-does-your-company-do' => '$what_does_your_company_do','core-team' => '$core_team','what-is-unique-selling-point' => '$what_is_unique_selling_point','go-to-market' => '$go_to_market','any-other-information' => '$any_other_information','link-to-url' => '$link_to_url','file-01' => '$file','date' => date('Y-m-d H:i:s')));
}
請告訴我正確的方法來做到這一點。
什麼是「沒有工作意味着」?你有錯誤還是數據庫沒有得到更新 –
數據庫只是沒有得到更新 – Kaloupi
我們肯定需要了解更多信息。另外,爲什麼不使用這個完善的插件呢? https://wordpress.org/plugins/contact-form-7-to-database-extension/ – Fencer04