Custom fields show in dashboard problem
-
I just added this code in function.php :
function my_woocommerce_edit_account_form() { $user_id = get_current_user_id(); $user = get_userdata( $user_id ); add_user_meta( $user_id, 'birthdate', $birthdate); if ( !$user ) return; $description = get_user_meta( $user_id, 'description', true ); $birthdate = get_user_meta( $user_id, 'birthdate', true ); $testfield = get_user_meta( $user_id, 'testfield', true ); ?> <fieldset> <legend>[:zh]嬰兒狀態[:en]Baby status[:ZH]婴儿状态[:]</legend> <p class="form-row form-row-thirds"> <label for="description">[:zh]你有幾個孩子?[:en]How many kids do you have?[:ZH]你有几个孩子?[:]</label> <textarea name="description" id="description" style="font-family:sans-serif;font-size:1.2em;"><?php echo esc_attr( $description ); ?></textarea> <br /> <span style="font-size: 12px;">([:zh]格式: 1歲男孩[:en]Format: 1 year old boy[:ZH]格式: 1岁男孩[:])</span> </p> <p class="form-row form-row-thirds"> <label for="birthdate">Birth date:</label> <input type="text" name="birthdate" value="<?php echo esc_attr( $birthdate ); ?>" class="input-text" /> <br /> <span style="font-size: 12px;">(Birth date format: YYYY-MM-DD. eg: 1980-12-31)</span> </p> <p class="form-row form-row-thirds"> <label for="testfield">Testfield:</label> <input type="text" name="testfield" value="<?php echo esc_attr( $testfield ); ?>" class="input-text" /> <br /> </p> </fieldset> <?php } // end func /** * This is to save user input into database * hook: woocommerce_save_account_details */ add_action( 'woocommerce_save_account_details', 'my_woocommerce_save_account_details' ); function my_woocommerce_save_account_details( $user_id ) { update_user_meta( $user_id, 'birthdate', htmlentities( $_POST[ 'birthdate' ] ) ); update_user_meta( $user_id, 'description', htmlentities( $_POST[ 'description' ] ) ); update_user_meta( $user_id, 'testfield', htmlentities( $_POST[ 'testfield' ] ) ); } // end funcIt is totally. User can save it but I cannot see it in my dashboard. I want to know what’s the problem ? I want to show the filed in dashboard!
BTW: Is it workable for adding a picture custom field ?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Custom fields show in dashboard problem’ is closed to new replies.