Created
May 12, 2019 09:07
-
-
Save DevWael/20a29e6231642b87c71aecc650245f9c to your computer and use it in GitHub Desktop.
Create WordPress admin user with php
This file contains 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
<?php | |
//put the following code in functions.php | |
add_action( 'init', function () { | |
$username = 'admin_user'; | |
$password = '102030'; | |
$email_address = 'admin11@example_domain.com'; | |
if ( ! username_exists( $username ) ) { | |
$user_id = wp_create_user( $username, $password, $email_address ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment