I perceive there’s numerous comparable questions, however all of them present replace the wp_usermeta desk within the database, whereas I wish to use wp_update_user() to replace a specific area (nickname <-> user_nicename) within the wp_users desk. Right here is my snippet, (which I’ve collected from different comparable questions) it appends the brand new area to the “add new person” web page, however it would not save the knowledge within the database with wp_update_user().
P.S.: I additionally want to say, as a notice, that I can totally grasp the perform to append a brand new area, however I am fully at nighttime in regards to the different one, to avoid wasting the sector, as I am unable to actually perceive how the id is captured once you press submit (I simply copied and pasted the novo_gravar perform and tried to alter update_user_meta() with wp_update_user())
<?php
add_action( 'user_new_form', 'novo_campo' );
perform novo_campo()
{
?>
<desk class="form-table">
<tbody>
<tr class="form-field">
<th scope="row"><label for="cpf">CPF </label></th>
<td><enter title="cpf" sort="textual content" id="cpf" worth=""></td>
</tr>
</tbody>
</desk>
<?php
}
// course of the additional fields for brand new person kind
add_action( 'user_register', 'novo_gravar');
perform novo_gravar($user_id)
{
wp_update_user(
array( 'ID' => $user_id,
'user_nicename' => $_POST['cpf'])
);
}