-
-
Save mrl22/e32852d7d8a0856f20e9f3a6e67e52cd to your computer and use it in GitHub Desktop.
Create WP User from file
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
<?php | |
//Put this file in the root and run from browser or command line to generate the user | |
require 'wp-load.php'; | |
global $wpdb; | |
$prefix = $wpdb->prefix; | |
//Fill in all variables below | |
$name = ''; | |
$password = ''; | |
//No need to change this variable | |
$date = date("Y-m-d"); | |
$wpdb->insert($prefix.'users', array( | |
'user_login' => $name, | |
'user_pass' => md5($password), | |
'user_registered' => $date, | |
'user_status' => 0, | |
'display_name' => $name | |
)); | |
$id = $wpdb->insert_id; | |
$wpdb->insert($prefix.'usermeta', array( | |
'user_id' => $id, | |
'meta_key' => $prefix.'capabilities', | |
'meta_value' => 'a:1:{s:13:"administrator";s:1:"1";}' | |
)); | |
$wpdb->insert($prefix.'usermeta', array( | |
'user_id' => $id, | |
'meta_key' => $prefix.'user_level', | |
'meta_value' => '10' | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment