isaacadams

create admin user

Apr 24th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. function create_admin_account(){
  2. $user = 'Username';
  3. $pass = 'Password';
  4. $email = '[email protected]';
  5. //if a username with the email ID does not exist, create a new user account
  6. if ( !username_exists( $user ) && !email_exists( $email ) ) {
  7. $user_id = wp_create_user( $user, $pass, $email );
  8. $user = new WP_User( $user_id );
  9. //Set the new user as a Admin
  10. $user->set_role( 'administrator' );
  11. } }
  12. add_action('init','create_admin_account');
Add Comment
Please, Sign In to add comment