ID; //reassign the username variable to ensure everything is up to date $errors = false; 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.', 'absprivacy' ); } /* 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'] ) && false === $errors && ! empty( $_POST['password'] ) ) { if ( strtolower( $_POST['password'] ) !== strtolower( $_POST['password2'] ) || empty( $_POST['password2'] ) ) { $errors = __( 'Your passwords do not match.', 'absprivacy' ); } else { wp_set_password( $_POST['password'], $user_id ); } } if ( false === $errors ) { //no errors, so lets update 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', 'absprivacy' ) . '

'; } 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 ?>