Forked from johnregan3/stream-user-generator.php
Last active
August 29, 2015 14:00
-
-
Save c3mdigital/11318369 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Plugin Name: Stream User Generator | |
* Description: Generates X-Team users for testing | |
* Version: 0.1 | |
* Author: johnregan3 | |
* Author URI: http://johnregan3.me | |
* | |
* USE: | |
* Upload this into your Plugins directory. | |
* Upon Activation, this will automatically generate 8 X-Team users. | |
* Simply Deactivate the plugin after activation. | |
*/ | |
register_activation_hook( __FILE__, 'wp_stream_create_users' ); | |
function wp_stream_create_users( $x_teamers ) { | |
$plugin = plugin_basename( __FILE__ ); | |
$plugin_data = get_plugin_data( __FILE__, false ); | |
$x_teamers = array( | |
'frankie' => array( | |
'username' => 'frankiej', | |
'first_name' => 'Frankie', | |
'last_name' => 'Jarrett', | |
'email' => '[email protected]', | |
'role' => 'administrator', | |
'password' => 'test', | |
), | |
'weston' => array( | |
'username' => 'westonr', | |
'first_name' => 'Weston', | |
'last_name' => 'Ruter', | |
'email' => '[email protected]', | |
'role' => 'editor', | |
'password' => 'test', | |
), | |
'topher' => array( | |
'username' => 'topher', | |
'first_name' => 'Chris', | |
'last_name' => 'Topher', | |
'email' => '[email protected]', | |
'role' => 'administrator', | |
'password' => 'test', | |
), | |
'luke' => array( | |
'username' => 'lukec', | |
'first_name' => 'Luke', | |
'last_name' => 'Carbis', | |
'email' => '[email protected]', | |
'role' => 'author', | |
'password' => 'test', | |
), | |
'chris' => array( | |
'username' => 'chriso', | |
'first_name' => 'Chris', | |
'last_name' => 'Olbekson', | |
'email' => '[email protected]', | |
'role' => 'editor', | |
'password' => 'test', | |
), | |
'shady' => array( | |
'username' => 'shadys', | |
'first_name' => 'Shady', | |
'last_name' => 'Sharaf', | |
'email' => '[email protected]', | |
'role' => 'administrator', | |
'password' => 'test', | |
), | |
'john' => array( | |
'username' => 'johnr', | |
'first_name' => 'John', | |
'last_name' => 'Regan', | |
'email' => '[email protected]', | |
'role' => 'administrator', | |
'password' => 'test', | |
), | |
'jonathan' => array( | |
'username' => 'jonathanb', | |
'first_name' => 'Jonathan', | |
'last_name' => 'Bardo', | |
'email' => '[email protected]', | |
'role' => 'contributor', | |
'password' => 'test', | |
), | |
); | |
$users = array(); | |
foreach ( $x_teamers as $user ) { | |
$user_id = username_exists( $user['username'] ); | |
if ( ! $user_id ) { | |
wp_create_user( $user['username'], $user['password'], $user['email'] ); | |
} | |
$user_id = username_exists( $user['username'] ); | |
$users[] = $user['username']; | |
wp_update_user( | |
array( | |
'ID' => $user_id, | |
'first_name' => $user['first_name'], | |
'last_name' => $user['last_name'], | |
'role' => $user['role'], | |
'user_email' => $user['email'], | |
) | |
); | |
} | |
$users = implode( ', ', $users ); | |
wp_die( "<strong>{$plugin_data['Name']}</strong> has ran and created the following users: $users , and has been deactivated!<br /><br />Back to the WordPress <a href='" . get_admin_url( null, 'plugins.php' ) . "'>Plugins page</a>." ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So cool, Chris! I didn't know anyone could "Self-deactivate" a plugin.