Advertisement
Guest User

Untitled

a guest
Apr 13th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. /* --------------------------
  2.     Add user from functions.php
  3. -------------------------- */
  4.  
  5. add_action('init', 'add_my_user');
  6. function add_my_user() {
  7.     $username = 'username123';
  8.     $email = 'name@example.com';
  9.     $password = 'password123';
  10.  
  11.     $user_id = username_exists( $username );
  12.     if ( !$user_id && email_exists($email) == false ) {
  13.         $user_id = wp_create_user( $username, $password, $email );
  14.         if( !is_wp_error($user_id) ) {
  15.             $user = get_user_by( 'id', $user_id );
  16.             $user->set_role( 'administrator' );
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement