b34b602e by Jeff Balicki

Department/Branch Settings

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 623de9b5
...@@ -255,67 +255,38 @@ function wpa_34245() { ...@@ -255,67 +255,38 @@ function wpa_34245() {
255 } 255 }
256 256
257 add_action( 'profile_update', function ( $user_id, $old_user_data ) { 257 add_action( 'profile_update', function ( $user_id, $old_user_data ) {
258 update_office_email($user_id); 258 //update_office_email($user_id);
259 update_branch_fax($user_id); 259 update_branch_fax($user_id);
260 }, 10, 2 ); 260 }, 10, 2 );
261 261
262 262
263 263
264 function update_branch_fax($userID) { 264 function update_branch_fax($userID) {
265 // if query var is not present just return 265 $department_branch = get_user_meta($userID, 'department_branch', true );
266 266 $department_fax = find_branch_info($department_branch, 'fax');
267 $department_branch = get_user_meta($userID, 'department_branch', true ); 267 update_user_meta( $userID, 'phone_number_12', $department_fax);
268 switch($department_branch){
269 case "Cranbrook Branch":
270 update_user_meta( $userID, 'phone_number_12', '250 426 7370' );
271 break;
272 case "Commercial Department":
273 update_user_meta( $userID, 'phone_number_12', '250 426 0879' );
274 break;
275 case "Elkford Branch":
276 update_user_meta( $userID, 'phone_number_12', '250 865 7537' );
277 break;
278 case "Sparwood Branch":
279 update_user_meta( $userID, 'phone_number_12', '250 425 0047' );
280 break;
281 case "Fernie Branch":
282 update_user_meta($userID, 'phone_number_12', '250 423 9223' );
283 break;
284 case "Castlegar Branch":
285 update_user_meta( $userID, 'phone_number_12', '250 365 2913' );
286 break;
287 case "Slocan Valley Branch":
288 update_user_meta( $userID, 'phone_number_12', '250 226 7351' );
289 break;
290 case "Greenwood Branch":
291 update_user_meta($userID, 'phone_number_12', '250 445 9902' );
292 break;
293 default:
294 echo "No department_branch set.<br>";
295 break;
296 }
297 } 268 }
298 269
299 270
300 function update_office_email($userID) { 271 function update_office_email($userID) {
301 $department_branch = get_user_meta( $userID, 'department_branch', true ); 272 $department_branch = get_user_meta( $userID, 'department_branch', true );
302 switch($department_branch){ 273 $department_email = find_branch_info($department_branch, 'email');
303 case "Administration Department": 274 update_user_meta( $userID, 'department_email',$department_email );
304 update_user_meta( $userID, 'department_email', 'administration@stellervista.com' ); 275
305 break; 276 }
306 case "Accounting Department":
307 update_user_meta( $userID, 'department_email', 'treasuryaccount@stellervista.com' );
308 break;
309 case "Commercial Department":
310 update_user_meta( $userID, 'department_email', 'commercial@stellervista.com' );
311 break;
312 case "Member Solutions Centre":
313 update_user_meta( $userID, 'department_email', 'msc@stellervista.com' );
314 break;
315 default:
316
317 break;
318 }
319
320 }
321 277
278
279 function find_branch_info($department_branch, $field){
280
281 if( have_rows('departments_and_branches', 'option') ):
282 while ( have_rows('departments_and_branches' , 'option') ) : the_row();
283 if(get_sub_field('departmentbranch') == $department_branch ):
284 error_log("Found branch: ".$department_branch);
285 error_log("Found branch: ".$field);
286 return get_sub_field($field);
287 endif;
288 endwhile;
289 endif;
290
291 }
292
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -39,16 +39,16 @@ function my_acf_init_block_types() { ...@@ -39,16 +39,16 @@ function my_acf_init_block_types() {
39 } 39 }
40 } 40 }
41 41
42 // if( function_exists('acf_add_options_page') ) { 42 if( function_exists('acf_add_options_page') ) {
43 43
44 // acf_add_options_page(array( 44 acf_add_options_page(array(
45 // 'page_title' => 'Theme General Settings', 45 'page_title' => 'Department/Branch Settings',
46 // 'menu_title' => 'Theme Settings', 46 'menu_title' => 'Department/Branch',
47 // 'menu_slug' => 'theme-general-settings', 47 'menu_slug' => 'department-branch-settings',
48 // 'capability' => 'edit_posts', 48 'capability' => 'edit_posts',
49 // 'redirect' => false 49 'redirect' => false
50 // )); 50 ));
51 51
52 // } 52 }
53 53
54 54
......