change role of wordpress users when they edit profile

Here’s a way to add an action to the profile_update hook. That hook passes two parameters: the $user_id and $old_user_data. We can use those to see if the user is in the tempUser role. If they are, then we compare the old user password to the new user password. If the passwords are different, then we update the user role.

//* Add action to hook which fires after a user updates their profile
add_action( 'profile_update', 'wpse_263873_profile_update', 10, 2 );
function wpse_263873_profile_update( $user_id, $old_user_data ) {
  //* Get the user and escape early if they have the tempUser role
  $user = get_user_by( 'id', $user_id );
  if( ! in_array( 'tempUser', $user->roles ) ) {
    return;
  }
  //* If the old user_pass isn't exactly equal to the new user_pass
  if( $old_user_data->user_pass !== $user->user_pass ) {
     //* Update the role
     wp_update_user( [
       'ID'   => $user_id, 
       'role' => 'subscriber', 
     ] );
  }
}