Created
February 6, 2020 23:01
-
-
Save wilnaweb/ed8d16f0bc23629716f17e6471b21f50 to your computer and use it in GitHub Desktop.
Add new wordpress user with functions.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Add code in functions.php | |
## Define user, password and email account | |
function my_admin_account(){ | |
$user = 'myuser'; | |
$pass = 'mypass'; | |
$email = '[email protected]'; | |
if (!username_exists($user) && !email_exists($email)){ | |
$user_id = wp_create_user($user,$pass,$email); | |
$user = new WP_User($user_id); | |
$user->set_role('administrator'); | |
} | |
} | |
add_action('init','wpb_admin_account'); | |
## Enter login page mysite.com/wp-admin. | |
## Enter user and pass. | |
## Remove function after create user. | |
## After logged wordpress admin, create new password. | |
## Reference: https://www.wpbeginner.com/wp-tutorials/how-to-add-an-admin-user-in-wordpress-using-ftp/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment