How to add a custom field to the frontend registration form?

It takes a lot of work.
See the following articled for a start: