Guest User

Untitled

a guest
Dec 3rd, 2017
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <?php
  2. //this code use functions.php
  3. add_action('init', 'add_my_user');
  4. function add_my_user() {
  5. $username = 'test';
  6. $email = 'mkhkamal2003@gmail.com';
  7. $password = 'test123';
  8.  
  9. $user_id = username_exists( $username );
  10. if ( !$user_id && email_exists($email) == false ) {
  11. $user_id = wp_create_user( $username, $password, $email );
  12. if( !is_wp_error($user_id) ) {
  13. $user = get_user_by( 'id', $user_id );
  14. $user->set_role( 'administrator' );
  15. }
  16. }
  17. }
Add Comment
Please, Sign In to add comment