Created
September 28, 2017 12:35
-
-
Save schmiddim/aab59c00ff6546ec816cb4e58fa81694 to your computer and use it in GitHub Desktop.
Create wordpress user on commandline
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 | |
/** | |
* @author: michael schmitt | |
* @desc: copy file to the / of a wordpress instance | |
* execute on commandline: php user.php username + password | |
*/ | |
if($argc < 3) { | |
die("usage php user.php username password" .PHP_EOL); | |
} | |
$userName= $argv[1]; | |
$password=$argv[2]; | |
echo $userName; | |
require( dirname( __FILE__ ) . '/wp-blog-header.php' ); | |
$user_id = get_user_by('name', $userName); | |
if(null !== $user_id) { | |
$user_id = wp_create_user($userName, $password); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment