0
我試圖從一個接觸的形式(CF7)數據插入到兩個不同的表 我敢肯定我的代碼是正確的,但仍沒有插入從接觸形式的數據庫
下面的代碼
remove_all_filters ('wpcf7_before_send_mail');
add_action('wpcf7_before_send_mail', 'my_conversion');
function my_conversion($cf7)
{
$email = $cf7->posted_data["email"];
$name = $cf7->posted_data["lastname"];
$tel = $cf7->posted_data["cf_3"];
$fonction = $cf7->posted_data["cf_1"];
$entreprise = $cf7->posted_data["cf_2"];
$newsletter = $cf7->posted_data["newsletter"];
insert($email, $name, $tel, $fonction,$entreprise,$newsletter);
}
function insert($email, $name, $tel, $fonction,$entreprise,$newsletter)
{
global $wpdb;
$wpdb->insert("wp_wysija_user", array(
"user_id" => NULL,
"wpuser_id" =>"0",
"email" => $email,
"firstname" => "",
"lastname" => $name,
"ffonc" => $fonction,
"fent" => $entreprise,
"ftel" => $tel,
"ip" => "0",
"confirmed_ip" => NULL,
"confirmed_at" => NULL,
"last_opened" => NULL,
"last_clicked" => NULL,
"keyuser" => NULL,
"created_at" => "",
"status" => "0",
"domain" => ""
));
if($newsletter == "oui")
{
$wpdb->insert("wp_wysija_user_list", array(
"list" => "3",
"user_id" => NULL,
"sub_date" => "1430666348",
"unsub_date" => "0"
));
}
}
我知道有,沒有工作的另一個插件,但我寧願我的方式去做
感謝, 雷米。
你是對的,這是插入功能不起作用 使用var_dump它顯示字段是空的,但我不明白爲什麼 是否有什麼與CF7形式? –
可能有些值是錯誤的或被數據庫拒絕。嘗試消毒你的輸入。 https://codex.wordpress.org/Class_Reference/wpdb#INSERT_rows – Blackbam