PluginProbe
WPCargo Track & Trace / trunk
WPCargo Track & Trace vtrunk
8.0.5 8.0.3 8.0.4 trunk 6.10.0 6.10.1 6.10.2 6.10.3 6.10.4 6.10.5 6.10.6 6.10.8 6.11.0 6.12.2 6.13.0 6.13.1 6.13.3 6.13.4 6.13.5 6.13.6 6.9.0 6.9.1 6.9.2 6.9.3 6.9.4 All 38 releases
wpcargo / admin / classes / class-user.php

class-user.php in WPCargo Track & Trace trunk, at admin/classes/class-user.php

60 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit; // Exit if accessed directly
4 }
5 class WPCargo_User{
6 function __construct(){
7 add_action( 'show_user_profile', array( $this, 'extra_profile_fields' ) );
8 add_action( 'edit_user_profile', array( $this, 'extra_profile_fields' ) );
9 add_action( 'personal_options_update', array( $this, 'save_extra_profile_fields' ) );
10 add_action( 'edit_user_profile_update', array( $this, 'save_extra_profile_fields' ) );
11 }
12 function extra_profile_fields( $user ) {
13 $current_offset = get_option('gmt_offset');
14 $tzstring = get_option('timezone_string');
15 $check_zone_info = true;
16 // Remove old Etc mappings. Fallback to gmt_offset.
17 if ( false !== strpos($tzstring,'Etc/GMT') )
18 $tzstring = '';
19 if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists
20 $check_zone_info = false;
21 if ( 0 == $current_offset )
22 $tzstring = 'UTC+0';
23 elseif ($current_offset < 0)
24 $tzstring = 'UTC' . $current_offset;
25 else
26 $tzstring = 'UTC+' . $current_offset;
27 }
28 $user_timezone = get_user_meta( $user->ID, 'wpc_user_timezone', true );
29 $tzstring = $user_timezone ? $user_timezone : $tzstring ;
30 require_once( WPCARGO_PLUGIN_PATH.'admin/templates/user-profile.tpl.php');
31 }
32
33 function save_extra_profile_fields( $user_id ) {
34 if ( !current_user_can( 'edit_user', $user_id ) ){
35 return false;
36 }
37 if( isset( $_POST['wpc_user_timezone'] ) ){
38 update_user_meta( $user_id, 'wpc_user_timezone', sanitize_text_field( $_POST['wpc_user_timezone'] ) );
39 }
40 if( isset( $_POST['business_reg'] ) ){
41 update_user_meta( $user_id, 'business_reg', sanitize_text_field( $_POST['business_reg'] ) );
42 }
43
44 if( isset( $_POST['gst_account'] ) ){
45 update_user_meta( $user_id, 'gst_account', sanitize_text_field( $_POST['gst_account'] ) );
46 }
47
48 if( isset( $_POST['min_notification'] ) ){
49 update_user_meta( $user_id, 'min_notification', sanitize_text_field( $_POST['min_notification'] ) );
50 }
51
52 if( isset( $_POST['wpcargo_phone'] ) ){
53 update_user_meta( $user_id, 'wpcargo_phone', sanitize_text_field( $_POST['wpcargo_phone'] ) );
54 }
55 if( isset( $_POST['company_logo'] ) ){
56 update_user_meta( $user_id, 'company_logo', sanitize_text_field( $_POST['company_logo'] ) );
57 }
58 }
59 }
60 new WPCargo_User;