array( 'title' => __( 'Customer Billing Address', 'woocommerce' ), 'fields' => array( 'billing_first_name' => array( 'label' => __( 'First name', 'woocommerce' ), 'description' => '' ), 'billing_last_name' => array( 'label' => __( 'Last name', 'woocommerce' ), 'description' => '' ), 'billing_company' => array( 'label' => __( 'Company', 'woocommerce' ), 'description' => '' ), 'billing_address_1' => array( 'label' => __( 'Address 1', 'woocommerce' ), 'description' => '' ), 'billing_address_2' => array( 'label' => __( 'Address 2', 'woocommerce' ), 'description' => '' ), 'billing_city' => array( 'label' => __( 'City', 'woocommerce' ), 'description' => '' ), 'billing_postcode' => array( 'label' => __( 'Postcode', 'woocommerce' ), 'description' => '' ), 'billing_state' => array( 'label' => __( 'State/County', 'woocommerce' ), 'description' => __( 'State/County or state code', 'woocommerce' ), ), 'billing_country' => array( 'label' => __( 'Country', 'woocommerce' ), 'description' => __( '2 letter Country code', 'woocommerce' ), ), 'billing_phone' => array( 'label' => __( 'Telephone', 'woocommerce' ), 'description' => '' ), 'billing_email' => array( 'label' => __( 'Email', 'woocommerce' ), 'description' => '' ) ) ), 'shipping' => array( 'title' => __( 'Customer Shipping Address', 'woocommerce' ), 'fields' => array( 'shipping_first_name' => array( 'label' => __( 'First name', 'woocommerce' ), 'description' => '' ), 'shipping_last_name' => array( 'label' => __( 'Last name', 'woocommerce' ), 'description' => '' ), 'shipping_company' => array( 'label' => __( 'Company', 'woocommerce' ), 'description' => '' ), 'shipping_address_1' => array( 'label' => __( 'Address 1', 'woocommerce' ), 'description' => '' ), 'shipping_address_2' => array( 'label' => __( 'Address 2', 'woocommerce' ), 'description' => '' ), 'shipping_city' => array( 'label' => __( 'City', 'woocommerce' ), 'description' => '' ), 'shipping_postcode' => array( 'label' => __( 'Postcode', 'woocommerce' ), 'description' => '' ), 'shipping_state' => array( 'label' => __( 'State/County', 'woocommerce' ), 'description' => __( 'State/County or state code', 'woocommerce' ) ), 'shipping_country' => array( 'label' => __( 'Country', 'woocommerce' ), 'description' => __( '2 letter Country code', 'woocommerce' ) ) ) ) )); return $show_fields; } /** * Show Address Fields on edit user pages. * * @param mixed $user User (object) being displayed */ public function add_customer_meta_fields( $user ) { if ( ! current_user_can( 'manage_woocommerce' ) ) return; $show_fields = $this->get_customer_meta_fields(); foreach( $show_fields as $fieldset ) : ?>

$field ) : ?>

get_customer_meta_fields(); foreach( $save_fields as $fieldset ) foreach( $fieldset['fields'] as $key => $field ) if ( isset( $_POST[ $key ] ) ) update_user_meta( $user_id, $key, wc_clean( $_POST[ $key ] ) ); } /** * Display the API key info for a user * * @since 2.1 * @param WP_User $user */ public function add_api_key_field( $user ) { if ( ! current_user_can( 'manage_woocommerce' ) ) return; $permissions = array( 'read' => __( 'Read', 'woocommerce' ), 'write' => __( 'Write', 'woocommerce' ), 'read_write' => __( 'Read/Write', 'woocommerce' ), ); if ( current_user_can( 'edit_user', $user->ID ) ) { ?>
woocommerce_api_consumer_key ) ) : ?>  woocommerce_api_consumer_key ?>
 woocommerce_api_consumer_secret; ?>
 
woocommerce_api_consumer_key ) ) { $consumer_key = 'ck_' . hash( 'md5', $user->user_login . date( 'U' ) . mt_rand() ); update_user_meta( $user_id, 'woocommerce_api_consumer_key', $consumer_key ); } else { delete_user_meta( $user_id, 'woocommerce_api_consumer_key' ); } // consumer secret if ( empty( $user->woocommerce_api_consumer_secret ) ) { $consumer_secret = 'cs_' . hash( 'md5', $user->ID . date( 'U' ) . mt_rand() ); update_user_meta( $user_id, 'woocommerce_api_consumer_secret', $consumer_secret ); } else { delete_user_meta( $user_id, 'woocommerce_api_consumer_secret' ); } // permissions if ( empty( $user->woocommerce_api_key_permissions ) ) { if ( isset( $_POST['woocommerce_api_key_permissions'] ) ) { $permissions = ( in_array( $_POST['woocommerce_api_key_permissions'], array( 'read', 'write', 'read_write' ) ) ) ? $_POST['woocommerce_api_key_permissions'] : 'read'; } else { $permissions = 'read'; } update_user_meta( $user_id, 'woocommerce_api_key_permissions', $permissions ); } else { delete_user_meta( $user_id, 'woocommerce_api_key_permissions' ); } } else { // updating permissions for key if ( ! empty( $_POST['woocommerce_api_key_permissions'] ) && $user->woocommerce_api_key_permissions !== $_POST['woocommerce_api_key_permissions'] ) { $permissions = ( ! in_array( $_POST['woocommerce_api_key_permissions'], array( 'read', 'write', 'read_write' ) ) ) ? 'read' : $_POST['woocommerce_api_key_permissions']; update_user_meta( $user_id, 'woocommerce_api_key_permissions', $permissions ); } } } } } endif; return new WC_Admin_Profile();