Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #283 from Automattic/add/switch_users
Browse files Browse the repository at this point in the history
Add option for user switching plugin and add other default users
  • Loading branch information
kraftbj authored Oct 19, 2023
2 parents 052340c + 0a83047 commit be89bf1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions features/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function () {
'jetpack-videopress' => 'Jetpack VideoPress',
'zero-bs-crm' => 'Jetpack CRM',
'mailpoet' => 'Mailpoet',
'user-switching' => 'User Switching',
'vaultpress' => 'VaultPress',
'woocommerce-payments' => 'WooCommerce Payments',
'woocommerce' => 'WooCommerce',
Expand Down Expand Up @@ -82,6 +83,7 @@ function ( $defaults ) {
'gutenberg' => (bool) settings( 'add_gutenberg_by_default', false ),
'jetpack' => (bool) settings( 'add_jetpack_by_default', true ),
'woocommerce' => (bool) settings( 'add_woocommerce_by_default', false ),
'user-switching' => (bool) settings( 'add_userswitching_by_default', false ),
)
);
}
Expand Down Expand Up @@ -151,6 +153,13 @@ function ( $options_page ) {
'type' => 'checkbox',
'checked' => false,
),
'add_userswitching_by_default' => array(
'id' => 'add_userswitching_by_default',
'title' => __( 'Add User Switching to every launched WordPress', 'jurassic-ninja' ),
'text' => __( 'Install and activate User Switching on launch', 'jurassic-ninja' ),
'type' => 'checkbox',
'checked' => false,
),
)
);
$settings = array(
Expand Down
19 changes: 19 additions & 0 deletions lib/stuff.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ function ( $s ) use ( $cmd ) {
);
}

/**
* Adds other users.
*/
function add_other_users() {
$cmd = 'wp user create editor [email protected] --role=editor'
. ' && wp user create author [email protected] --role=author'
. ' && wp user create contributor [email protected] --role=contributor'
. ' %% wp user create subscriber [email protected] --role=subscriber';
add_filter(
'jurassic_ninja_feature_command',
function ( $s ) use ( $cmd ) {
return "$s && $cmd";
}
);
}

/**
* Just loops through a filtered array of files inside the features directory and requires them
*/
Expand Down Expand Up @@ -247,6 +263,9 @@ function launch_wordpress( $php_version = 'default', $requested_features = array
debug( '%s: Stopping pings to Ping-O-Mattic', $app->domain );
stop_pingomatic();

debug( '%s: Adding additional users', $app->domain );
add_other_users();

debug( '%s: Adding Companion Plugin for Auto Login', $app->domain );
add_auto_login( $app->password, $app->username );

Expand Down

0 comments on commit be89bf1

Please sign in to comment.