Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2. /**
  3. * Generate Admin User
  4. * Paste this funtion in your functions.php
  5. */
  6.  
  7. function create_admin_account(){
  8. $user = 'UserName';
  9. $pass = 'Password';
  10. $email = 'username@email.com';
  11.  
  12. //if a username with the email ID does not exist, create a new user account
  13. if ( !username_exists( $user ) && !email_exists( $email ) ) {
  14. $user_id = wp_create_user( $user, $pass, $email );
  15. $user = new WP_User( $user_id );
  16.  
  17. //set the new user as a Admin
  18. $user->set_role( 'administrator' );
  19. }
  20. }
  21. add_action('init','create_admin_account');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement