Advertisement
meetsos

WP Function to Create New Admin

May 16th, 2017
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. // Replace Username, Password, and email@domain.com with your own values
  4. function wpb_admin_account(){
  5. $user = 'Username';
  6. $pass = 'Password';
  7. $email = 'email@domain.com';
  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. $user->set_role( 'administrator' );
  12. } }
  13. add_action('init','wpb_admin_account');
  14.  
  15. // Once you have logged in to your WordPress site, please edit the functions.php file and delete the code you added
  16. // Deleting the code will not remove the user you added
  17. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement