Skip to content

Instantly share code, notes, and snippets.

@seedprod
Created April 26, 2016 19:08
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 seedprod/10d8cf7453e90768d5fb3ce79a599ce7 to your computer and use it in GitHub Desktop.
Save seedprod/10d8cf7453e90768d5fb3ce79a599ce7 to your computer and use it in GitHub Desktop.
<?php
add_action( 'init', 'delete_site');
function delete_site(){
$action = $_REQUEST['action'];
$email = $_REQUEST['email'];
if($email == 'support@seedprod.com'){
exit();
}
if($action == 'remove'){
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
require_once( ABSPATH . 'wp-admin/includes/user.php' );
$user = get_user_by( 'email', $email );
if(!empty($user)){
$blogs = get_blogs_of_user( $user->ID );
if(!empty($blogs)){
foreach ( $blogs as $blog ) {
wpmu_delete_blog( $blog->userblog_id, true );
//var_dump($blog->userblog_id);
}
}
wpmu_delete_user( $user->ID );
exit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment