Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mototeam
Created March 9, 2020 12:54
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 mototeam/31edd521288b7f995edd0802acddc439 to your computer and use it in GitHub Desktop.
Save mototeam/31edd521288b7f995edd0802acddc439 to your computer and use it in GitHub Desktop.
This plugin allows you to add registered user to a new Sandbox.
<?php
/*
* Plugin Name: MotoPress Demo - Add User to Sandbox
* Plugin URI: https://motopress.com
* Description: This plugin allows you to add registered user to a new Sandbox.
* Author: MotoPress
* Version: 1.0
* Author URI: https://motopress.com
* Network: True
*/
defined( 'ABSPATH' ) || exit;
function motopress_demo_add_user_to_blog( $source_id, $target_id ) {
// select registered user
$vendor_user = get_user_by( 'email', 'vendor@local.loc' );
if ( $vendor_user ) {
$vendor_user_id = $vendor_user->ID;
// add user to sandbox
add_user_to_blog(
$target_id,
$vendor_user_id,
'administrator'
);
}
}
add_action('mp_demo_create_sandbox', 'motopress_demo_add_user_to_blog', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment