Add new users to "add new user" page on admin's dashboard
I understand there's a lot of similar questions, but all of them show how to update the wp_usermeta table in the database, whereas I want to use wp_update_user() to update a particular field (nickname - user_nicename) in the wp_users table. Here is my snippet, (which I have collected from other similar questions) it appends the new field to the add new user page, but it doesn't save the information in the database with wp_update_user().
P.S.: I also would like to say, as a note, that I can fully grasp the function to append a new field, but I'm completely in the dark about the other one, to save the field, as I can't really understand how the id is captured when you press submit (I just copied and pasted the novo_gravar function and tried to change update_user_meta() with wp_update_user())
?php
add_action( 'user_new_form', 'novo_campo' );
function novo_campo()
{
?
table class=form-table
tbody
tr class=form-field
th scope=rowlabel for=cpfCPF /label/th
tdinput name=cpf type=text id=cpf value=/td
/tr
/tbody
/table
?php
}
// process the extra fields for new user form
add_action( 'user_register', 'novo_gravar');
function novo_gravar($user_id)
{
wp_update_user(
array( 'ID' = $user_id,
'user_nicename' = $_POST['cpf'])
);
}
Topic actions user-registration Wordpress
Category Web