Created
July 14, 2014 13:27
-
-
Save cb99999/146a6a06a9d956de784d to your computer and use it in GitHub Desktop.
Wordpress - add users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*---------------------------- | |
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