Skip to content

Instantly share code, notes, and snippets.

@azanebrain
Created June 29, 2013 23:16
Show Gist options
  • Save azanebrain/5893082 to your computer and use it in GitHub Desktop.
Save azanebrain/5893082 to your computer and use it in GitHub Desktop.
Create WordPress Users with a function
//This would be good for setting up a stock dev environment. So instead of dumping in a DB, you would run an initializer with options
$users[0] = array(
'first_name' => 'Daniel',
'last_name' => 'Pataki',
'user_login' => 'danielpataki',
'user_pass' => 'mysupersecretpass',
'user_email' => 'mysupermail@mymail.com',
'display_name' => 'Daniel',
'description' => 'Guitar-wielding Web developer',
'role' => 'administrator'
)
$users[1] = array(
'first_name' => 'Viki',
'last_name' => 'Makra',
'user_login' => 'viki',
'user_pass' => 'hersupersecretpass',
'user_email' => 'hersupermail@mymail.com',
'display_name' => 'Viki',
'description' => 'Front-end developer and awesome admin handler',
'role' => 'editor'
)
foreach( $users as $user ){
wp_insert_user( $user );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment