Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Read more {@link https://codex.wordpress.org/Function_Reference/wp_set_password}
- */
- wp_set_password( 'newpasswd', 1 );
- /**
- * Create a new user with admin caps
- *
- * Read more {@link https://codex.wordpress.org/Function_Reference/wp_create_user}
- *
- * @version WP 4.7.3
- */
- add_action( 'init', 'wpse262478_add_new_adminuser' );
- function wpse262478_add_new_adminuser()
- {
- $username = 'aname';
- $email = 'whatever@domain.com';
- $password = 'LZTf$f$FR)Y@xye';
- $user_id = username_exists( $username );
- if ( !$user_id && email_exists( $email ) == false )
- {
- $user_id = wp_create_user( $username, $password, $email );
- if( !is_wp_error( $user_id ) )
- {
- $user = get_user_by( 'id', $user_id );
- $user->set_role( 'administrator' );
- }
- }
- } // end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement