Skip to content

Instantly share code, notes, and snippets.

@cb99999
Created July 14, 2014 13:27
Show Gist options
  • Save cb99999/146a6a06a9d956de784d to your computer and use it in GitHub Desktop.
Save cb99999/146a6a06a9d956de784d to your computer and use it in GitHub Desktop.
Wordpress - add users
/*----------------------------
wordpress function to add
users to database programatically
-----------------------------*/
function fb_wp_insert_user() {
$user_data = array(
'ID' => '',
'user_pass' => wp_generate_password(),
'user_login' => 'dummy',
'user_nicename' => 'Dummy',
'user_url' => '',
'user_email' => 'dummy@example.com',
'display_name' => 'Dummy',
'nickname' => 'dummy',
'first_name' => 'Dummy',
'user_registered' => '2010-05-15 05:55:55',
'role' => get_option('default_role') // Use default role or another role, e.g. 'editor'
);
$user_id = wp_insert_user( $user_data );
}
add_action( 'admin_init', 'fb_wp_insert_user' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment