I am trying to add an extra field to the user-edit.php page on WordPress.
I want to add it to the “About this User/You” section right above the “Biographical Info” field. I had already edited the file to add another but for some reason, it will not save the information I enter into it.
<table class="form-table">
<tr class="user-job-title-wrap">
<th><label for="job_title"><?php _e('Job Title'); ?></label></th>
<td><input type="text" name="job_title" id="job_title" value="<?php echo esc_attr( $profileuser->job_title ) ?>" class="regular-text ltr" />
</td>
</tr>
<tr class="user-description-wrap">
<th><label for="description"><?php _e('Biographical Info'); ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
<p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td>
</tr>
...
It does add the correct meta_key to the wp_usermeta db but the meta_value stays blank. If I manually enter the meta_value in the db and reload the user edit page, the value is correctly loaded into the input field, but any changes made to this field are not recorded to the db.
Here are the wordpress hooks to add fields and saving updated fields data:
–(Updated)– You can use only
save_extra_user_fields
below to solve your issue (â¦saving informationâ¦), and keep your code if you like.This code goes on
function.php
file of your active child theme or themeâ¦Using your Custom User Fields data with php:
get_the_author_meta( 'your_field_slug', $userID );
the_author_meta( 'your_field_slug', $userID );