You have, at least, three wrong things in your code. First. You are “returning” before you try to update the user info, so the wp_update_user()
function is not executed. Second, you have the user ID hardcoded, so you always trying to modify the nickname of the user with ID = 1
return $tableuserinf;
$user_id = 1;
$nicksname = $_POST['fepusernick'];
wp_update_user( array ( 'ID' => $user_id, 'nickname' => $nicksname ) ) ;
Should be:
$user_id = $current_user->ID;
$nicksname = $_POST['fepusernick'];
wp_update_user( array ( 'ID' => $user_id, 'nickname' => $nicksname ) ) ;
return $tableuserinf;
You can go further and make some checks:
$user_id = $current_user->ID;
// Not sure if sanitize_user() is needed or is executed by wp_update_user(). Anyway, it doesn't hurt
$nicksname = isset($_POST['fepusernick']) ? sanitize_user($_POST['fepusernick']) : '';
//check if new nickname is different before performing the update operation
if($nicksname != $current_user->nickname){
wp_update_user( array ( 'ID' => $user_id, 'nickname' => $nicksname ) ) ;
}
return $tableuserinf;