ID; //reassign the username variable to ensure everything is up to date if( isset($_POST['wp-submit']) ){ // The form has been submitted /* Here we check for errors. We'll throw an error if the user has * left the first name, last name, or email address empty. */ if( empty($_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['user_email']) ){ $errors = 'You must enter a value for first name, last name, and email address.'; } /* Here we check if the user is trying to submit a new password. * We only update the password if there are no previous errors, * and if both inputted passwords match. */ if( isset($_POST['password']) && empty($errors) && !empty($_POST['password']) ){ if( strtolower( $_POST['password'] ) != strtolower( $_POST['password2'] ) || empty($_POST['password2']) ){ $errors = 'Your passwords do not match.'; }else{ wp_set_password( $_POST['password'], $user_id ); } } if( empty($errors) ){ //no errors, so lets udate the user wp_update_user( array( 'ID' => $user_id, 'first_name' => htmlentities( trim($_POST['first_name']) ), 'last_name' => htmlentities( trim($_POST['last_name']) ), 'user_email' => htmlentities( trim($_POST['user_email']) ) ) ); echo '

Your profile has been updated

'; }else{ echo '

ERROR: ' . $errors . '

'; } } $user = new WP_User( $user_id ); // use this instead of $userdata so that the changes are reflected after a user updates the form ?>

You may edit your profile using the form below.

You may also change your password (optional).