b34b602e by Jeff Balicki

Department/Branch Settings

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 623de9b5
......@@ -255,67 +255,38 @@ function wpa_34245() {
}
add_action( 'profile_update', function ( $user_id, $old_user_data ) {
update_office_email($user_id);
//update_office_email($user_id);
update_branch_fax($user_id);
}, 10, 2 );
function update_branch_fax($userID) {
// if query var is not present just return
$department_branch = get_user_meta($userID, 'department_branch', true );
switch($department_branch){
case "Cranbrook Branch":
update_user_meta( $userID, 'phone_number_12', '250 426 7370' );
break;
case "Commercial Department":
update_user_meta( $userID, 'phone_number_12', '250 426 0879' );
break;
case "Elkford Branch":
update_user_meta( $userID, 'phone_number_12', '250 865 7537' );
break;
case "Sparwood Branch":
update_user_meta( $userID, 'phone_number_12', '250 425 0047' );
break;
case "Fernie Branch":
update_user_meta($userID, 'phone_number_12', '250 423 9223' );
break;
case "Castlegar Branch":
update_user_meta( $userID, 'phone_number_12', '250 365 2913' );
break;
case "Slocan Valley Branch":
update_user_meta( $userID, 'phone_number_12', '250 226 7351' );
break;
case "Greenwood Branch":
update_user_meta($userID, 'phone_number_12', '250 445 9902' );
break;
default:
echo "No department_branch set.<br>";
break;
}
$department_fax = find_branch_info($department_branch, 'fax');
update_user_meta( $userID, 'phone_number_12', $department_fax);
}
function update_office_email($userID) {
$department_branch = get_user_meta( $userID, 'department_branch', true );
switch($department_branch){
case "Administration Department":
update_user_meta( $userID, 'department_email', 'administration@stellervista.com' );
break;
case "Accounting Department":
update_user_meta( $userID, 'department_email', 'treasuryaccount@stellervista.com' );
break;
case "Commercial Department":
update_user_meta( $userID, 'department_email', 'commercial@stellervista.com' );
break;
case "Member Solutions Centre":
update_user_meta( $userID, 'department_email', 'msc@stellervista.com' );
break;
default:
break;
$department_email = find_branch_info($department_branch, 'email');
update_user_meta( $userID, 'department_email',$department_email );
}
function find_branch_info($department_branch, $field){
if( have_rows('departments_and_branches', 'option') ):
while ( have_rows('departments_and_branches' , 'option') ) : the_row();
if(get_sub_field('departmentbranch') == $department_branch ):
error_log("Found branch: ".$department_branch);
error_log("Found branch: ".$field);
return get_sub_field($field);
endif;
endwhile;
endif;
}
\ No newline at end of file
......
......@@ -39,16 +39,16 @@ function my_acf_init_block_types() {
}
}
// if( function_exists('acf_add_options_page') ) {
// acf_add_options_page(array(
// 'page_title' => 'Theme General Settings',
// 'menu_title' => 'Theme Settings',
// 'menu_slug' => 'theme-general-settings',
// 'capability' => 'edit_posts',
// 'redirect' => false
// ));
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Department/Branch Settings',
'menu_title' => 'Department/Branch',
'menu_slug' => 'department-branch-settings',
'capability' => 'edit_posts',
'redirect' => false
));
// }
}
......