Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function create_new_admin_user_account() {
- $username = 'new_admin';
- $password = 'New_Password!123';
- $email = '[email protected]';
- //Check to see if an account exists with the given username and email address value.
- if ( !username_exists($username) && !email_exists($email) ) {
- //All clear. Go ahead.
- //Create WP User entry
- $user_id = wp_create_user($username, $password, $email);
- //WP User object
- $wp_user = new WP_User($user_id);
- //Set the role of this user to administrator.
- $wp_user->set_role('administrator');
- }
- }
- //Run the function with WordPress's "init" hook is triggered.
- add_action('init', 'create_new_admin_user_account');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement