Skip to content

Instantly share code, notes, and snippets.

@mrl22
Forked from brendonexus/user-create.php
Created October 30, 2017 12:51
Show Gist options
  • Save mrl22/e32852d7d8a0856f20e9f3a6e67e52cd to your computer and use it in GitHub Desktop.
Save mrl22/e32852d7d8a0856f20e9f3a6e67e52cd to your computer and use it in GitHub Desktop.
Create WP User from file
<?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