PHP Code To Add New User in WordPress

This solution enables you to add a new user via your functions file.

The code enables you to set the following:

  • The username
  • The password
  • The email address
  • The role

add-new-user

You can use this code to create a new administrator or add any number of users via your functions file, a plugin, theme or MU folder.

If, for some reason you cannot reset your password, you might want to use this solution.

Simply add the following PHP to your functions file and it will create a new user with administrator access:

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.