Skip to content

Instantly share code, notes, and snippets.

@c3mdigital
Forked from johnregan3/stream-user-generator.php
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c3mdigital/11318369 to your computer and use it in GitHub Desktop.
Save c3mdigital/11318369 to your computer and use it in GitHub Desktop.
<?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' => 'frankie@x-team.com',
'role' => 'administrator',
'password' => 'test',
),
'weston' => array(
'username' => 'westonr',
'first_name' => 'Weston',
'last_name' => 'Ruter',
'email' => 'weston@x-team.com',
'role' => 'editor',
'password' => 'test',
),
'topher' => array(
'username' => 'topher',
'first_name' => 'Chris',
'last_name' => 'Topher',
'email' => 'topher@x-team.com',
'role' => 'administrator',
'password' => 'test',
),
'luke' => array(
'username' => 'lukec',
'first_name' => 'Luke',
'last_name' => 'Carbis',
'email' => 'luke.carbis@x-team.com',
'role' => 'author',
'password' => 'test',
),
'chris' => array(
'username' => 'chriso',
'first_name' => 'Chris',
'last_name' => 'Olbekson',
'email' => 'chris.olbekson@x-team.com',
'role' => 'editor',
'password' => 'test',
),
'shady' => array(
'username' => 'shadys',
'first_name' => 'Shady',
'last_name' => 'Sharaf',
'email' => 'shady.sharaf@x-team.com',
'role' => 'administrator',
'password' => 'test',
),
'john' => array(
'username' => 'johnr',
'first_name' => 'John',
'last_name' => 'Regan',
'email' => 'john.regan@x-team.com',
'role' => 'administrator',
'password' => 'test',
),
'jonathan' => array(
'username' => 'jonathanb',
'first_name' => 'Jonathan',
'last_name' => 'Bardo',
'email' => 'jonathan.bardo@x-team.com',
'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>." );
}
@johnregan3
Copy link

So cool, Chris! I didn't know anyone could "Self-deactivate" a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment