Created
March 9, 2020 12:54
-
-
Save mototeam/31edd521288b7f995edd0802acddc439 to your computer and use it in GitHub Desktop.
This plugin allows you to add registered user to a new Sandbox.
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: 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