Custom form from user registration form not showing new fields in D7
Is there a reason you need to use code? You could just add the fields to the user profile and check "required on registration" to make them show up during registration.