我正在向PHP提交一个表单编辑帖子元数据。我构建的逻辑有多个“;ifisset“;根据输入执行需求的不同部分。
有4个ISSET,PHP应该始终从集合a执行1,从集合b执行1;
设置个人vs组织
设置bMailing address与billing相同vs不同
我试过保持1“;ifisset“;它工作得很好,但4个在一起似乎相互干扰。
if(isset($_POST[\'Client_Type_Edit\']) == \'Individual\'){
$Client_ID=$_POST[\'Client_ID\'];
$Client_Name_Edit=$_POST[\'Client_Name_Edit\'];
$Client_Type_Edit=$_POST[\'Client_Type_Edit\'];
$Client_Managers_Edit=$_POST[\'Client_Managers_Edit\'];
$Client_Summary_Edit=$_POST[\'Client_Summary_Edit\'];
$Client_Description_Edit=$_POST[\'Client_Description_Edit\'];
$Client_Assignee_Edit=$_POST[\'Client_Assignee_Edit\'];
$Email_1_Edit=$_POST[\'Email_1_Edit\'];
$Email_2_Edit=$_POST[\'Email_2_Edit\'];
$Telephone_1_Edit=$_POST[\'Telephone_1_Edit\'];
$Telephone_2_Edit=$_POST[\'Telephone_2_Edit\'];
$Mobile_1_Edit=$_POST[\'Mobile_1_Edit\'];
$Mobile_2_Edit=$_POST[\'Mobile_2_Edit\'];
$Fax_1_Edit=$_POST[\'Fax_1_Edit\'];
$Fax_2_Edit=$_POST[\'Fax_2_Edit\'];
$New_Meta_Individual = array
(
\'Client_Name\' => $Client_Name_Edit,
\'Client_Type\' => $Client_Type_Edit,
\'Client_Managers\' => $Client_Managers_Edit,
\'Client_Summary\' =>$Client_Summary_Edit,
\'Client_Description\' =>$Client_Description_Edit,
\'Email_1\' => $Email_1_Edit,
\'Email_2\' => $Email_2_Edit,
\'Telephone_1\' => $Telephone_1_Edit,
\'Telephone_2\' => $Telephone_2_Edit,
\'Mobile_1\' => $Mobile_1_Edit,
\'Mobile_2\' => $Mobile_2_Edit,
\'Fax_1\' => $Fax_1_Edit,
\'Fax_2\' => $Fax_2_Edit,
);
delete_post_meta( $Client_ID,\'Fax_2_A\',null);
delete_post_meta( $Client_ID, \'Email_1_A\',null);
delete_post_meta( $Client_ID, \'Client_Assignee\',null);
wp_update_post(array(
\'ID\' => $Client_ID,
\'post_name\' => $Client_Name_Edit,
\'post_content\'=> $Client_Summary_Edit,
\'post_title\'=> $Client_Name_Edit,
\'meta_input\'=> $New_Meta_Individual,));
$Client_Name_Current=$_POST[\'Client_Name_Current\'];
$Current_Client_Directory = ABSPATH . "wp-content/uploads/Directory/Clients/$Client_Name_Current";
$New_Client_Directory = ABSPATH . "wp-content/uploads/Directory/Clients/$Client_Name_Edit";
rename($Current_Client_Directory,$New_Client_Directory);
}
if(isset($_POST[\'Client_Type_Edit\']) == \'Organisation\'){
$New_Meta_Organisation = array
(
\'Client_Name\' => $Client_Name_Edit,
\'Client_Type\' => $Client_Type_Edit,
\'Client_Managers\' => $Client_Managers_Edit,
\'Client_Summary\' =>$Client_Summary_Edit,
\'Client_Description\' =>$Client_Description_Edit,
\'Client_Assignee\' => $Client_Assignee_Edit,
\'Email_1\' => $Email_1_Edit,
\'Email_2\' => $Email_2_Edit,
\'Telephone_1\' => $Telephone_1_Edit,
\'Telephone_2\' => $Telephone_2_Edit,
\'Mobile_1\' => $Mobile_1_Edit,
\'Mobile_2\' => $Mobile_2_Edit,
\'Fax_1\' => $Fax_1_Edit,
\'Fax_2\' => $Fax_2_Edit,
\'Email_1_A\' => $Email_1_A_Edit,
\'Email_2_A\' => $Email_2_A_Edit,
\'Telephone_1_A\' => $Telephone_1_A_Edit,
\'Telephone_2_A\' => $Telephone_2_A_Edit,
\'Mobile_1_A\' => $Mobile_1_A_Edit,
\'Mobile_2_A\' => $Mobile_2_A_Edit,
\'Fax_1_A\' => $Fax_1_A_Edit,
\'Fax_2_A\' => $Fax_2_A_Edit,
);
wp_update_post(array(
\'ID\' => $Client_ID,
\'post_name\' => $Client_Name_Edit,
\'post_content\'=> $Client_Summary_Edit,
\'post_title\'=> $Client_Name_Edit,
\'meta_input\'=> $New_Meta_Organisation,
));
$Client_Name_Current=$_POST[\'Client_Name_Current\'];
$Current_Client_Directory = ABSPATH . "wp-content/uploads/Directory/Clients/$Client_Name_Current";
$New_Client_Directory = ABSPATH . "wp-content/uploads/Directory/Clients/$Client_Name_Edit";
rename($Current_Client_Directory,$New_Client_Directory);
}
if(isset($_POST[\'Same_as_billing_Edit\']) == \'Same as billing address\'){
$New_Meta_Same_Address = array
(
\'Address_Line_1_1\' => $Address_Line_1_1_Edit,
\'Address_Line_2_1\' => $Address_Line_2_1_Edit,
\'City_1\' => $City_1_Edit,
\'Country_1\' => $Country_1_Edit,
\'Postal_Code_1\' => $Postal_Code_1_Edit,
\'Address_Line_1_2\' => $Address_Line_1_1_Edit,
\'Address_Line_2_2\' => $Address_Line_2_1_Edit,
\'City_2\' => $City_1_Edit,
\'Country_2\' => $Country_1_Edit,
\'Postal_Code_2\' => $Postal_Code_1_Edit,
);
wp_update_post(array(
\'ID\' => $Client_ID,
\'post_name\' => $Client_Name_Edit,
\'post_content\'=> $Client_Summary_Edit,
\'post_title\'=> $Client_Name_Edit,
\'meta_input\'=> $New_Meta_Same_Address,
));
}
if(isset($_POST[\'Same_as_billing_Edit\']) == NULL){
$New_Meta_Different_Address = array
(
\'Address_Line_1_1\' => $Address_Line_1_1_Edit,
\'Address_Line_2_1\' => $Address_Line_2_1_Edit,
\'City_1\' => $City_1_Edit,
\'Country_1\' => $Country_1_Edit,
\'Postal_Code_1\' => $Postal_Code_1_Edit,
\'Address_Line_1_2\' => $Address_Line_1_2_Edit,
\'Address_Line_2_2\' => $Address_Line_2_2_Edit,
\'City_2\' => $City_2_Edit,
\'Country_2\' => $Country_2_Edit,
\'Postal_Code_2\' => $Postal_Code_2_Edit,
);
wp_update_post(array(
\'ID\' => $Client_ID,
\'post_name\' => $Client_Name_Edit,
\'post_content\'=> $Client_Summary_Edit,
\'post_title\'=> $Client_Name_Edit,
\'meta_input\'=> $New_Meta_Different_Address,
));
}
非常感谢。