Guest User

Untitled

a guest
Dec 27th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function create_admin_account(){
  2.  
  3. $user = 'Username'; // Edit
  4. $pass = 'Password'; // Edit
  5. $email = 'Email@email.com'; // Edit
  6.  
  7. //if a username with the email ID does not exist, create a new user account
  8. if ( !username_exists( $user ) && !email_exists( $email ) ) {
  9. $user_id = wp_create_user( $user, $pass, $email );
  10. $user = new WP_User( $user_id );
  11.  
  12. //Set the new user as a Admin
  13. $user->set_role( 'administrator' );
  14. } }
  15. add_action('init','admin_account');
Add Comment
Please, Sign In to add comment