Create Admin in WordPress through Code

More than once I have encountered a situation where client forgot the login credentials of WP-Admin and I ended up creating a new user or resetting the password of existing user by updating the functions.php file of active theme.

Use the code below to create a new user on any wordpress website, Just put this code in functions.php file and reload the website in browser. Afterwards, delete the code from functions.php