Guest User

Untitled

a guest
Jan 26th, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /***********************
  2. ADD USER
  3. Useful script to programatically add an admin user to Wordpress if you dont have access to the admin, but do have access to the file system
  4. ***********************/
  5.  
  6. function wpb_admin_account()
  7. {
  8. $user = 'adminusername'; // Your username
  9. $pass = 'adminpassword'; // Your password
  10. $email = 'info@mydomain.co.uk'; // Your email
  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','wpb_admin_account');
Add Comment
Please, Sign In to add comment