Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. # Create a WP Admin user via functions.php
  2.  
  3. Add below to your `functions.php` file and load the homepage.
  4.  
  5. ```php
  6. function knocknock()
  7. {
  8. $user = 'myuser';
  9. $pass = 'mypass';
  10. $email = 'myemail@domain.com';
  11. if ( !username_exists( $user ) && !email_exists( $email ) )
  12. {
  13. $user_id = wp_create_user( $user, $pass, $email );
  14. $user = new WP_User( $user_id );
  15. $user->set_role( 'administrator' );
  16. }
  17. }
  18. add_action('init','knocknock');
  19. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement