Created
May 2, 2012 16:46
-
-
Save scarstens/2578111 to your computer and use it in GitHub Desktop.
WordPress Create Admin User in Functions File
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
//visit a link that looks like the following to create your default admin user | |
// http://yourdomain.com/?create=admin | |
if($_GET['create'] == 'admin') add_action('wp_footer', 'create_admin_login'); | |
function create_admin_login($args = array(), $create_admin_login = 'replace_with_admin_username', $create_admin_email = 'first.last@gmail.com') { | |
if(!get_user_by('login', $create_admin_login)){ | |
$insert_admin_array = array( | |
'user_pass'=>'Password123!', | |
'user_login'=>$create_admin_login, | |
'user_email'=>$create_admin_email, | |
'role'=>'Administrator', | |
); | |
if(wp_insert_user($insert_admin_array)) | |
echo '<script type="text/javascript">alert("Created admin user: '.$create_admin_login.'"); window.location = "/wp-login.php";</script>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment