WordPress has a lot of pre-written functions that can be used without rewriting.
If wordpress does not have a function to support your problem, you should not write a new function, but use Hooks (action and filter) to intervene and change wordpress’s existing functions to suit your requirements.
Some simple examples in the figure below:
- Redirect after user login based on user type (use 1 filter)
- Add multiple information fields to the user list in Admin WordPress (using 2 filters)
- Add favicon for WordPress Admin (use 1 action)