WC_Admin_Profile::add_customer_meta_fields( WP_User $user )
Show Address Fields on edit user pages.
Description Description
Parameters Parameters
- $user
-
(Required)
Source Source
File: includes/admin/class-wc-admin-profile.php
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | public function add_customer_meta_fields( $user ) { if ( ! apply_filters( 'woocommerce_current_user_can_edit_customer_meta_fields' , current_user_can( 'manage_woocommerce' ), $user ->ID ) ) { return ; } $show_fields = $this ->get_customer_meta_fields(); foreach ( $show_fields as $fieldset_key => $fieldset ) : ?> <h2><?php echo $fieldset [ 'title' ]; ?></h2> <table class = "form-table" id= "<?php echo esc_attr( 'fieldset-' . $fieldset_key ); ?>" > <?php foreach ( $fieldset [ 'fields' ] as $key => $field ) : ?> <tr> <th> <label for = "<?php echo esc_attr( $key ); ?>" ><?php echo esc_html( $field [ 'label' ] ); ?></label> </th> <td> <?php if ( ! empty ( $field [ 'type' ] ) && 'select' === $field [ 'type' ] ) : ?> <select name= "<?php echo esc_attr( $key ); ?>" id= "<?php echo esc_attr( $key ); ?>" class = "<?php echo esc_attr( $field['class'] ); ?>" style= "width: 25em;" > <?php $selected = esc_attr( get_user_meta( $user ->ID, $key , true ) ); foreach ( $field [ 'options' ] as $option_key => $option_value ) : ?> <option value= "<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected , $option_key , true ); ?>><?php echo esc_html( $option_value ); ?></option> <?php endforeach ; ?> </select> <?php elseif ( ! empty ( $field [ 'type' ] ) && 'checkbox' === $field [ 'type' ] ) : ?> <input type= "checkbox" name= "<?php echo esc_attr( $key ); ?>" id= "<?php echo esc_attr( $key ); ?>" value= "1" class = "<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user ->ID, $key , true ), 1, true ); ?> /> <?php elseif ( ! empty ( $field [ 'type' ] ) && 'button' === $field [ 'type' ] ) : ?> <button type= "button" id= "<?php echo esc_attr( $key ); ?>" class = "button <?php echo esc_attr( $field['class'] ); ?>" ><?php echo esc_html( $field [ 'text' ] ); ?></button> <?php else : ?> <input type= "text" name= "<?php echo esc_attr( $key ); ?>" id= "<?php echo esc_attr( $key ); ?>" value= "<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class = "<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> <?php endif ; ?> <p class = "description" ><?php echo wp_kses_post( $field [ 'description' ] ); ?></p> </td> </tr> <?php endforeach ; ?> </table> <?php endforeach ; } |