I am submitting a form to PHP edit post metadata. The logic I built is having multiple "ifisset" to execute different parts of the requirements based on the inputs.
There are 4 issets, the PHP should always execute 1 from set a, and 1 from set b"
set a Individual vs Organisation
set b Mailing adddress is same as billing vs is different
I have tried keeping 1 "ifisset" and it works fine, but 4 together seem to interfere with each other.
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,
));
}
Many thanks in advance.