SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | // ADD NEW ADMIN USER TO WORDPRESS | |
3 | // ---------------------------------- | |
4 | // Put this file in your Wordpress root directory and run it from your browser. | |
5 | // Delete it when you're done. | |
6 | ||
7 | require_once('wp-blog-header.php'); | |
8 | require_once('wp-includes/registration.php'); | |
9 | ||
10 | // ---------------------------------------------------- | |
11 | // CONFIG VARIABLES | |
12 | // Make sure that you set these before running the file. | |
13 | $newusername = 'lloyd_haze'; | |
14 | $newpassword = 'helloworld123'; | |
15 | - | $newemail = 'lloyd_haze@live.co.uk'; |
15 | + | $newemail = 'lloyd@groundedbodyscrub.co.uk'; |
16 | // ---------------------------------------------------- | |
17 | ||
18 | // This is just a security precaution, to make sure the above "Config Variables" | |
19 | // have been changed from their default values. | |
20 | if ( $newpassword != '1' && | |
21 | $newemail != '1' && | |
22 | $newusername !='1' ) | |
23 | { | |
24 | // Check that user doesn't already exist | |
25 | if ( !username_exists($newusername) && !email_exists($newemail) ) | |
26 | { | |
27 | // Create user and set role to administrator | |
28 | $user_id = wp_create_user( $newusername, $newpassword, $newemail); | |
29 | if ( is_int($user_id) ) | |
30 | { | |
31 | $wp_user_object = new WP_User($user_id); | |
32 | $wp_user_object->set_role('administrator'); | |
33 | echo 'Successfully created new admin user. Now delete this file!'; | |
34 | } | |
35 | else { | |
36 | echo 'Error with wp_insert_user. No users were created.'; | |
37 | } | |
38 | } | |
39 | else { | |
40 | echo 'This user or email already exists. Nothing was done.'; | |
41 | } | |
42 | } | |
43 | else { | |
44 | echo 'Whoops, looks like you did not set a password, username, or email'; | |
45 | echo 'before running the script. Set these variables and try again.'; | |
46 | } | |
47 | ?> |