Skip to content

Instantly share code, notes, and snippets.

@trvswgnr
Last active October 14, 2020 17:13
Show Gist options
  • Save trvswgnr/4e8c3e67d3ac48f93fbf07a195cbd7e2 to your computer and use it in GitHub Desktop.
Save trvswgnr/4e8c3e67d3ac48f93fbf07a195cbd7e2 to your computer and use it in GitHub Desktop.
Create a new WordPress user.
<?php
/**
* Add WordPress User
*
* @package taw
*/
/**
* Add WordPress Admin User
*/
function taw_add_wp_user() {
$user = 'someuser';
$pass = 'agoodpassword';
$email = 'myemail@mydomain.com';
if ( ! username_exists( $user ) && ! email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
// add_action( 'init', 'taw_add_wp_user' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment