public function __construct()
 {
     parent::__construct(site_url('pnfw/unregister/'), 'POST');
     global $wpdb;
     $push_tokens = $wpdb->get_blog_prefix() . 'push_tokens';
     $user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$push_tokens} WHERE token = %s AND os = %s", $this->token, $this->os));
     $res = $wpdb->delete($push_tokens, array("token" => $this->token, "os" => $this->os));
     if ($res === false) {
         $this->json_error('500', __('Unable to delete token', 'pnfw'));
     }
     $user = new WP_User($user_id);
     if (in_array(PNFW_Push_Notifications_for_WordPress_Lite::USER_ROLE, $user->roles) && empty($user->user_email)) {
         pnfw_log(PNFW_SYSTEM_LOG, sprintf(__("Automatically deleted the anonymous user %s (%s) since left without tokens.", 'pnfw'), $user->user_login, $user_id));
         require_once ABSPATH . 'wp-admin/includes/user.php';
         if (is_multisite()) {
             require_once ABSPATH . 'wp-admin/includes/ms.php';
             if (is_user_member_of_blog($user_id)) {
                 wpmu_delete_user($user_id);
             }
         } else {
             wp_delete_user($user_id);
         }
     }
     exit;
 }
Example #2
0
 public function tearDown()
 {
     global $wpdb;
     remove_action('bp_blogs_recorded_existing_blogs', array($this, 'set_autocommit_flag'));
     parent::tearDown();
     // If we detect that a COMMIT has been triggered during the test, clean up blog and user fixtures.
     if ($this->autocommitted) {
         if (is_multisite()) {
             foreach ($wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id != 1") as $blog_id) {
                 wpmu_delete_blog($blog_id, true);
             }
         }
         foreach ($wpdb->get_col("SELECT ID FROM {$wpdb->users} WHERE ID != 1") as $user_id) {
             if (is_multisite()) {
                 wpmu_delete_user($user_id);
             } else {
                 wp_delete_user($user_id);
             }
         }
     }
     $this->commit_transaction();
     // Reactivate any components that have been deactivated.
     foreach ($this->deactivated_components as $component) {
         buddypress()->active_components[$component] = 1;
     }
     $this->deactivated_components = array();
 }
 public static function wpTearDownAfterClass()
 {
     if (is_multisite()) {
         wpmu_delete_user(self::$user_id);
     } else {
         wp_delete_user(self::$user_id);
     }
 }
Example #4
0
 /**
  * Multisite-agnostic way to delete a user from the database.
  *
  * @since 4.3.0
  */
 public static function delete_user($user_id)
 {
     if (is_multisite()) {
         return wpmu_delete_user($user_id);
     } else {
         return wp_delete_user($user_id);
     }
 }
function pnfw_delete_plugin()
{
    global $wpdb;
    $table_name = $wpdb->get_blog_prefix() . 'push_tokens';
    $wpdb->query("DROP TABLE IF EXISTS {$table_name};");
    $table_name = $wpdb->get_blog_prefix() . 'push_viewed';
    $wpdb->query("DROP TABLE IF EXISTS {$table_name};");
    $table_name = $wpdb->get_blog_prefix() . 'push_sent';
    $wpdb->query("DROP TABLE IF EXISTS {$table_name};");
    $table_name = $wpdb->get_blog_prefix() . 'push_excluded_categories';
    $wpdb->query("DROP TABLE IF EXISTS {$table_name};");
    $table_name = $wpdb->get_blog_prefix() . 'push_logs';
    $wpdb->query("DROP TABLE IF EXISTS {$table_name};");
    $table_name = $wpdb->get_blog_prefix() . 'postmeta';
    $wpdb->query("DELETE FROM {$table_name} WHERE meta_key = 'pnfw_do_not_send_push_notifications_for_this_post' OR meta_key = 'pnfw_user_cat';");
    $user_query = new WP_User_Query(array('role' => 'app_subscriber'));
    foreach ($user_query->results as $user) {
        if (empty($user->user_email)) {
            if (is_multisite()) {
                require_once ABSPATH . 'wp-admin/includes/ms.php';
                if (is_user_member_of_blog($user->ID)) {
                    wpmu_delete_user($user->ID);
                }
            } else {
                wp_delete_user($user->ID);
            }
        }
    }
    delete_option('pnfw_db_version');
    delete_option('pnfw_posts_per_page');
    delete_option('pnfw_last_save_timestamp');
    delete_option('pnfw_enable_push_notifications');
    delete_option('pnfw_ios_push_notifications');
    delete_option('pnfw_android_push_notifications');
    delete_option('pnfw_kindle_push_notifications');
    delete_option('pnfw_url_scheme');
    delete_option('pnfw_ios_use_sandbox');
    delete_option('pnfw_sandbox_ssl_certificate_media_id');
    delete_option('pnfw_sandbox_ssl_certificate_password');
    delete_option('pnfw_production_ssl_certificate_media_id');
    delete_option('pnfw_production_ssl_certificate_password');
    delete_option('pnfw_ios_payload_sound');
    delete_option('pnfw_google_api_key');
    delete_option('pnfw_adm_client_id');
    delete_option('pnfw_adm_client_secret');
    delete_option('pnfw_api_consumer_key');
    delete_option('pnfw_api_consumer_secret');
    delete_option('pnfw_enabled_post_types');
    delete_option('pnfw_enabled_object_taxonomies');
    delete_option('pnfw_use_wpautop');
    delete_option('pnfw_disable_email_verification');
    delete_option('pnfw_add_message_field_in_payload');
    delete_option('pnfw_uninstall_data');
    flush_rewrite_rules();
}
 /**
  * On author pages, the queried object should only be set
  * to a user that's not a member of the blog if they
  * have at least one published post. This matches core behavior.
  *
  * @see https://core.trac.wordpress.org/changeset/27290
  */
 function test_author_queried_object_fix()
 {
     global $wp_rewrite, $coauthors_plus;
     /**
      * Set up
      */
     $author1 = $this->factory->user->create(array('user_login' => 'msauthor1'));
     $author2 = $this->factory->user->create(array('user_login' => 'msauthor2'));
     $blog2 = $this->factory->blog->create(array('user_id' => $author1));
     switch_to_blog($blog2);
     $wp_rewrite->init();
     $blog2_post1 = $this->factory->post->create(array('post_status' => 'publish', 'post_content' => rand_str(), 'post_title' => rand_str(), 'post_author' => $author1));
     /**
      * Author 1 is an author on the blog
      */
     $this->go_to(get_author_posts_url($author1));
     $this->assertQueryTrue('is_author', 'is_archive');
     /**
      * Author 2 is not yet an author on the blog
      */
     $this->go_to(get_author_posts_url($author2));
     $this->assertQueryTrue('is_404');
     // Add the user to the blog
     add_user_to_blog($blog2, $author2, 'author');
     /**
      * Author 2 is now on the blog, but not yet published
      */
     $this->go_to(get_author_posts_url($author2));
     $this->assertQueryTrue('is_author', 'is_archive');
     // Add the user as an author on the original post
     $author2_obj = get_user_by('id', $author2);
     $coauthors_plus->add_coauthors($blog2_post1, array($author2_obj->user_login), true);
     /**
      * Author 2 is now on the blog, and published
      */
     $this->go_to(get_author_posts_url($author2));
     $this->assertQueryTrue('is_author', 'is_archive');
     // Remove the user from the blog
     remove_user_from_blog($author2, $blog2);
     /**
      * Author 2 was removed from the blog, but still a published author
      */
     $this->go_to(get_author_posts_url($author2));
     $this->assertQueryTrue('is_author', 'is_archive');
     // Delete the user from the network
     wpmu_delete_user($author2);
     /**
      * Author 2 is no more
      */
     $this->go_to(get_author_posts_url($author2));
     $this->assertQueryTrue('is_404');
     $this->assertEquals(false, get_user_by('id', $author2));
     restore_current_blog();
 }
Example #7
0
function _destroy_user($user_id)
{
    //non-admin
    if (!function_exists('wp_delete_user')) {
        require_once ABSPATH . 'wp-admin/includes/user.php';
    }
    if (is_multisite()) {
        wpmu_delete_user($user_id);
    } else {
        wp_delete_user($user_id);
    }
}
Example #8
0
 public static function tearDownAfterClass()
 {
     if (is_multisite()) {
         wpmu_delete_user(self::$user_id);
     } else {
         wp_delete_user(self::$user_id);
     }
     foreach (self::$post_ids as $post_id) {
         wp_delete_post($post_id, true);
     }
     self::commit_transaction();
 }
 function test_wp_authenticate_spam_check_returns_wp_error_when_flagged()
 {
     if (!is_multisite()) {
         $this->markTestSkipped('This test applies to multisite only.');
     }
     $user_id = self::factory()->user->create(array('role' => 'contributor'));
     update_user_status($user_id, 'spam', 1);
     $user = new WP_User($user_id);
     $actual_user = wp_authenticate_spam_check($user);
     wpmu_delete_user($user_id);
     $this->assertInstanceOf('WP_Error', $actual_user);
 }
Example #10
0
 public static function tearDownAfterClass()
 {
     foreach (array_merge(self::$users, array(self::$fred_id)) as $user_id) {
         if (is_multisite()) {
             wpmu_delete_user($user_id);
         } else {
             wp_delete_user($user_id);
         }
     }
     foreach (self::$posts as $post_id) {
         wp_delete_post($post_id, true);
     }
     self::commit_transaction();
 }
 public static function tearDownAfterClass()
 {
     foreach (self::$groups as $group) {
         groups_delete_group($group);
     }
     if (is_multisite()) {
         wpmu_delete_user(self::$user);
         wpmu_delete_user(self::$admin_user);
     } else {
         wp_delete_user(self::$user);
         wp_delete_user(self::$admin_user);
     }
     self::commit_transaction();
 }
 public static function tearDownAfterClass()
 {
     foreach (self::$group_ids as $group_id) {
         groups_delete_group($group_id);
     }
     foreach (self::$user_ids as $user_id) {
         if (is_multisite()) {
             wpmu_delete_user($user_id);
         } else {
             wp_delete_user($user_id);
         }
     }
     self::commit_transaction();
 }
Example #13
0
 public static function tearDownAfterClass()
 {
     if (is_multisite()) {
         wpmu_delete_user(self::$editor_user);
         wpmu_delete_user(self::$author_user);
     } else {
         wp_delete_user(self::$editor_user);
         wp_delete_user(self::$author_user);
     }
     wp_delete_post(self::$editor_private_post, true);
     wp_delete_post(self::$author_private_post, true);
     wp_delete_post(self::$editor_privatefoo_post, true);
     wp_delete_post(self::$author_privatefoo_post, true);
     self::commit_transaction();
 }
 /**
  * Test that usermeta cache is cleared after user deletion.
  *
  * @ticket 19500
  */
 function test_get_blogs_of_user()
 {
     // Logged out users don't have blogs.
     $this->assertEquals(array(), get_blogs_of_user(0));
     $user_id = $this->factory->user->create(array('role' => 'subscriber'));
     $blogs = get_blogs_of_user($user_id);
     $this->assertEquals(array(1), array_keys($blogs));
     // Non-existent users don't have blogs.
     if (is_multisite()) {
         wpmu_delete_user($user_id);
     } else {
         wp_delete_user($user_id);
     }
     $user = new WP_User($user_id);
     $this->assertFalse($user->exists(), 'WP_User->exists');
     $this->assertEquals(array(), get_blogs_of_user($user_id));
 }
Example #15
0
 public function tearDown()
 {
     global $wpdb;
     parent::tearDown();
     if (is_multisite()) {
         foreach ($wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id != 1") as $blog_id) {
             wpmu_delete_blog($blog_id, true);
         }
     }
     foreach ($wpdb->get_col("SELECT ID FROM {$wpdb->users} WHERE ID != 1") as $user_id) {
         if (is_multisite()) {
             wpmu_delete_user($user_id);
         } else {
             wp_delete_user($user_id);
         }
     }
     $this->commit_transaction();
 }
Example #16
0
 /**
  * Import users from csv file and remove any existing users that is not.
  * @subcommand import-users
  * @synopsis <csv-file>
  */
 public function import_users($args, $assoc_args)
 {
     global $wpdb;
     $file = $args[0];
     if (!($fh = fopen($file, 'r'))) {
         return;
     }
     $users = array();
     if ($headers = fgetcsv($fh)) {
         while ($row = fgetcsv($fh)) {
             if (count($headers) != count($row)) {
                 continue;
             }
             $users[] = array_combine($headers, $row);
         }
     }
     fclose($fh);
     if (empty($users)) {
         return;
     }
     $users = wp_list_pluck($users, 'user_login');
     $blogs = $wpdb->get_results("SELECT * FROM {$wpdb->blogs}");
     $existing_users = get_users(array('blog_id' => 1));
     foreach ($existing_users as $user) {
         // don't remove super admin
         if ($user->ID == 1 || is_super_admin($user->ID)) {
             continue;
         }
         if (!in_array($user->user_login, $users)) {
             foreach ($blogs as $blog) {
                 remove_user_from_blog($user->ID, $blog->blog_id, 1);
                 printf("Remove user %s from %s\n", $user->user_login, $blog->domain);
             }
             printf("Delete user %s\n", $user->user_login);
             wpmu_delete_user($user->ID);
         }
     }
     switch_to_blog(1);
     add_filter('send_password_change_email', '__return_false');
     \WP_CLI\Utils\load_command('user');
     $user = new User_Command();
     $user->import_csv($args, $assoc_args);
     $this->add_network_users();
 }
Example #17
0
 /**
  * Delete one or more users from the current site.
  *
  * ## OPTIONS
  *
  * <user>...
  * : The user login, user email, or user ID of the user(s) to delete.
  *
  * [--network]
  * : On multisite, delete the user from the entire network.
  *
  * [--reassign=<user-id>]
  * : User ID to reassign the posts to.
  *
  * [--yes]
  * : Answer yes to any confirmation prompts.
  *
  * ## EXAMPLES
  *
  *     # Delete user 123 and reassign posts to user 567
  *     $ wp user delete 123 --reassign=567
  *     Success: Removed user 123 from http://example.com
  */
 public function delete($args, $assoc_args)
 {
     $network = \WP_CLI\Utils\get_flag_value($assoc_args, 'network') && is_multisite();
     $reassign = \WP_CLI\Utils\get_flag_value($assoc_args, 'reassign');
     if ($network && $reassign) {
         WP_CLI::error('Reassigning content to a different user is not supported on multisite.');
     }
     if (!$reassign) {
         WP_CLI::confirm('--reassign parameter not passed. All associated posts will be deleted. Proceed?', $assoc_args);
     }
     $users = $this->fetcher->get_many($args);
     parent::_delete($users, $assoc_args, function ($user) use($network, $reassign) {
         $user_id = $user->ID;
         if ($network) {
             $r = wpmu_delete_user($user_id);
             $message = "Deleted user {$user_id}.";
         } else {
             $r = wp_delete_user($user_id, $reassign);
             $message = "Removed user {$user_id} from " . home_url() . ".";
         }
         if ($r) {
             return array('success', $message);
         } else {
             return array('error', "Failed deleting user {$user_id}.");
         }
     });
 }
Example #18
0
                        }
                        if (!empty($_POST['delete']) && 'reassign' == $_POST['delete'][$blogid][$id]) {
                            remove_user_from_blog($id, $blogid, $user_id);
                        } else {
                            remove_user_from_blog($id, $blogid);
                        }
                    }
                }
            }
            $i = 0;
            if (is_array($_POST['user']) && !empty($_POST['user'])) {
                foreach ($_POST['user'] as $id) {
                    if (!current_user_can('delete_user', $id)) {
                        continue;
                    }
                    wpmu_delete_user($id);
                    $i++;
                }
            }
            if ($i == 1) {
                $deletefunction = 'delete';
            } else {
                $deletefunction = 'all_delete';
            }
            wp_redirect(add_query_arg(array('updated' => 'true', 'action' => $deletefunction), network_admin_url('users.php')));
            exit;
            break;
    }
}
$wp_list_table = _get_list_table('WP_MS_Users_List_Table');
$pagenum = $wp_list_table->get_pagenum();
Example #19
0
	function test_is_user_member_of_blog() {
		global $wpdb;

		$user1_id = $this->factory->user->create( array( 'role' => 'administrator' ) );

		$old_current = get_current_user_id();
		wp_set_current_user( $user1_id );

		$this->assertTrue( is_user_member_of_blog() );
		$this->assertTrue( is_user_member_of_blog( 0, 0 ) );
		$this->assertTrue( is_user_member_of_blog( 0, $wpdb->blogid ) );
		$this->assertTrue( is_user_member_of_blog( $user1_id ) );
		$this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) );

		$blog_ids = $this->factory->blog->create_many( 5 );
		foreach ( $blog_ids as $blog_id ) {
			$this->assertInternalType( 'int', $blog_id );
			$this->assertTrue( is_user_member_of_blog( $user1_id, $blog_id ) );
			$this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
			$this->assertFalse( is_user_member_of_blog( $user1_id, $blog_id ) );
		}

		wpmu_delete_user( $user1_id );
		$user = new WP_User( $user1_id );
		$this->assertFalse( $user->exists(), 'WP_User->exists' );
		$this->assertFalse( is_user_member_of_blog( $user1_id ), 'is_user_member_of_blog' );

		wp_set_current_user( $old_current );
	}
 public function test_update_existing_network_user_on_sub_site_adds_user_to_site()
 {
     if (!is_multisite()) {
         $this->markTestSkipped('Test requires multisite.');
     }
     $this->allow_user_to_manage_multisite();
     $params = array('username' => 'testuser123', 'password' => 'testpassword', 'email' => '*****@*****.**', 'name' => 'Test User 123', 'roles' => array('editor'));
     $request = new WP_REST_Request('POST', '/wp/v2/users');
     $request->add_header('content-type', 'application/x-www-form-urlencoded');
     $request->set_body_params($params);
     $response = $this->server->dispatch($request);
     $data = $response->get_data();
     $user_id = $data['id'];
     switch_to_blog(self::$site);
     $request = new WP_REST_Request('PUT', '/wp/v2/users/' . $user_id);
     $request->add_header('content-type', 'application/x-www-form-urlencoded');
     $request->set_body_params($params);
     $this->server->dispatch($request);
     restore_current_blog();
     $user_is_member = is_user_member_of_blog($user_id, self::$site);
     wpmu_delete_user($user_id);
     $this->assertTrue($user_is_member);
 }
/**
 * Process account deletion requests.
 *
 * Primarily used for self-deletions, as requested through Settings.
 *
 * @since 1.0.0
 *
 * @param int $user_id Optional. ID of the user to be deleted. Default: the
 *                     logged-in user.
 * @return bool True on success, false on failure.
 */
function bp_core_delete_account($user_id = 0)
{
    // Use logged in user ID if none is passed.
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    // Site admins cannot be deleted.
    if (is_super_admin($user_id)) {
        return false;
    }
    // Extra checks if user is not deleting themselves.
    if (bp_loggedin_user_id() !== absint($user_id)) {
        // Bail if current user cannot delete any users.
        if (!bp_current_user_can('delete_users')) {
            return false;
        }
        // Bail if current user cannot delete this user.
        if (!current_user_can_for_blog(bp_get_root_blog_id(), 'delete_user', $user_id)) {
            return false;
        }
    }
    /**
     * Fires before the processing of an account deletion.
     *
     * @since 1.6.0
     *
     * @param int $user_id ID of the user account being deleted.
     */
    do_action('bp_core_pre_delete_account', $user_id);
    // Specifically handle multi-site environment.
    if (is_multisite()) {
        require_once ABSPATH . '/wp-admin/includes/ms.php';
        require_once ABSPATH . '/wp-admin/includes/user.php';
        $retval = wpmu_delete_user($user_id);
        // Single site user deletion.
    } else {
        require_once ABSPATH . '/wp-admin/includes/user.php';
        $retval = wp_delete_user($user_id);
    }
    /**
     * Fires after the deletion of an account.
     *
     * @since 1.6.0
     *
     * @param int $user_id ID of the user account that was deleted.
     */
    do_action('bp_core_deleted_account', $user_id);
    return $retval;
}
 function delete($send_mail = true)
 {
     global $ultimatemember;
     do_action('um_delete_user_hook');
     do_action('um_delete_user', um_user('ID'));
     // send email notifications
     if ($send_mail) {
         $ultimatemember->mail->send(um_user('user_email'), 'deletion_email');
         $ultimatemember->mail->send(um_admin_email(), 'notification_deletion', array('admin' => true));
     }
     // remove uploads
     $ultimatemember->files->remove_dir(um_user_uploads_dir());
     // remove user
     if (is_multisite()) {
         if (!function_exists('wpmu_delete_user')) {
             require_once ABSPATH . 'wp-admin/includes/ms.php';
         }
         wpmu_delete_user($this->id);
     } else {
         if (!function_exists('wp_delete_user')) {
             require_once ABSPATH . 'wp-admin/includes/user.php';
         }
         wp_delete_user($this->id);
     }
 }
Example #23
0
 /**
  * Clean up shared fixtures.
  *
  * @since 4.1.0
  */
 public static function delete_shared_fixtures()
 {
     global $wp_rewrite;
     if (is_multisite()) {
         wpmu_delete_user(self::$author_id);
     } else {
         wp_delete_user(self::$author_id);
     }
     foreach (self::$post_ids as $pid) {
         wp_delete_post($pid, true);
     }
     foreach (self::$comment_ids as $cid) {
         wp_delete_comment($cid, true);
     }
     foreach (self::$term_ids as $tid => $tax) {
         wp_delete_term($tid, $tax);
     }
     self::$author_id = null;
     self::$post_ids = array();
     self::$comment_ids = array();
     self::$term_ids = array();
     self::$terms = array();
     self::commit_transaction();
 }
/**
 * Allows a user to completely remove their account from the system
 *
 * @package BuddyPress Core
 * @global object $bp Global BuddyPress settings object
 * @uses is_super_admin() Checks to see if the user is a site administrator.
 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs.
 * @uses wp_delete_user() Deletes a user from the system on singlesite installs.
 */
function bp_core_delete_account($user_id = 0)
{
    global $bp, $wp_version;
    if (!$user_id) {
        $user_id = $bp->loggedin_user->id;
    }
    // Make sure account deletion is not disabled
    if (!empty($bp->site_options['bp-disable-account-deletion']) && !$bp->loggedin_user->is_super_admin) {
        return false;
    }
    // Site admins cannot be deleted
    if (is_super_admin(bp_core_get_username($user_id))) {
        return false;
    }
    // Specifically handle multi-site environment
    if (is_multisite()) {
        if ($wp_version >= '3.0') {
            require ABSPATH . '/wp-admin/includes/ms.php';
        } else {
            require ABSPATH . '/wp-admin/includes/mu.php';
        }
        require ABSPATH . '/wp-admin/includes/user.php';
        return wpmu_delete_user($user_id);
        // Single site user deletion
    } else {
        require ABSPATH . '/wp-admin/includes/user.php';
        return wp_delete_user($user_id);
    }
}
 /**
  * Booking Payment
  * @since 1.3
  * @version 1.1
  */
 function booking_payment($result, $EM_Booking)
 {
     global $wpdb, $wp_rewrite, $EM_Notices;
     //make sure booking save was successful before we try anything
     if ($result) {
         // Event is not free
         if ($EM_Booking->get_price() > 0) {
             $ok = true;
             // User is excluded from using this gateway
             if ($this->core->exclude_user($EM_Booking->person_id)) {
                 $EM_Booking->add_error(__('You can not pay using this gateway.', 'mycred'));
                 $ok = false;
             } elseif (!$this->can_pay($EM_Booking)) {
                 $EM_Booking->add_error($this->core->template_tags_general($this->prefs['messages']['error']));
                 $ok = false;
             } elseif (!$this->has_paid($EM_Booking)) {
                 // Get Cost
                 $cost = $this->get_cost($EM_Booking);
                 // Charge
                 $this->core->add_creds('ticket_purchase', $EM_Booking->person_id, 0 - $cost, $this->prefs['log']['purchase'], $EM_Booking->event->post_id, array('ref_type' => 'post', 'bid' => (int) $EM_Booking->booking_id), $this->mycred_type);
                 // Log transaction with EM
                 $transaction_id = time() . $EM_Booking->person_id;
                 $EM_Booking->booking_meta[$this->gateway] = array('txn_id' => $transaction_id, 'amount' => $cost);
                 $this->record_transaction($EM_Booking, $EM_Booking->get_price(false, false, true), get_option('dbem_bookings_currency'), current_time('mysql'), $transaction_id, 'Completed', '');
                 // Profit sharing
                 if ($this->prefs['share'] != 0) {
                     $event_post = get_post((int) $EM_Booking->event->post_id);
                     if ($event_post !== NULL) {
                         $share = $this->prefs['share'] / 100 * $cost;
                         $this->core->add_creds('ticket_sale', $event_post->post_author, $share, $this->prefs['log']['purchase'], $event_post->ID, array('ref_type' => 'post', 'bid' => (int) $EM_Booking->booking_id), $this->mycred_type);
                     }
                 }
             } else {
                 $ok = false;
             }
             // Successfull Payment
             if ($ok) {
                 if (!get_option('em_' . $this->gateway . '_manual_approval', false) || !get_option('dbem_bookings_approval')) {
                     $EM_Booking->set_status(1, false);
                     //Approve
                 } else {
                     $EM_Booking->set_status(0, false);
                     //Set back to normal "pending"
                 }
             } else {
                 // Delete any user that got registered for this event
                 if (!is_user_logged_in() && get_option('dbem_bookings_anonymous') && !get_option('dbem_bookings_registration_disable') && !empty($EM_Booking->person_id)) {
                     $EM_Person = $EM_Booking->get_person();
                     if (strtotime($EM_Person->data->user_registered) >= $this->registered_timer) {
                         if (is_multisite()) {
                             include_once ABSPATH . '/wp-admin/includes/ms.php';
                             wpmu_delete_user($EM_Person->ID);
                         } else {
                             include_once ABSPATH . '/wp-admin/includes/user.php';
                             wp_delete_user($EM_Person->ID);
                         }
                         // remove email confirmation
                         global $EM_Notices;
                         $EM_Notices->notices['confirms'] = array();
                     }
                 }
                 // Delete booking
                 $EM_Booking->delete();
                 return false;
             }
         }
     }
     return $result;
 }
Example #26
0
 function test_super_admin_cannot_be_deleted()
 {
     if (isset($GLOBALS['super_admins'])) {
         $old_global = $GLOBALS['super_admins'];
         unset($GLOBALS['super_admins']);
     }
     $user_id = $this->factory->user->create();
     grant_super_admin($user_id);
     $this->assertFalse(wpmu_delete_user($user_id));
     if (isset($old_global)) {
         $GLOBALS['super_admins'] = $old_global;
     }
 }
/**
 * Allows a user to completely remove their account from the system
 *
 * @package BuddyPress Core
 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs.
 * @uses wp_delete_user() Deletes a user from the system on singlesite installs.
 */
function bp_core_delete_account($user_id = 0)
{
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    // Make sure account deletion is not disabled
    if (!bp_current_user_can('delete_users') && bp_disable_account_deletion()) {
        return false;
    }
    // Site admins cannot be deleted
    if (is_super_admin($user_id)) {
        return false;
    }
    do_action('bp_core_pre_delete_account', $user_id);
    // Specifically handle multi-site environment
    if (is_multisite()) {
        require ABSPATH . '/wp-admin/includes/ms.php';
        require ABSPATH . '/wp-admin/includes/user.php';
        $retval = wpmu_delete_user($user_id);
        // Single site user deletion
    } else {
        require ABSPATH . '/wp-admin/includes/user.php';
        $retval = wp_delete_user($user_id);
    }
    do_action('bp_core_deleted_account', $user_id);
    return $retval;
}
Example #28
0
 function delete_user($user_id)
 {
     if (is_multisite()) {
         wpmu_delete_user($user_id);
     } else {
         wp_delete_user($user_id);
     }
 }
Example #29
0
function userpro_process_form()
{
    global $userpro;
    if (!isset($_POST['_myuserpro_nonce']) || !wp_verify_nonce($_POST['_myuserpro_nonce'], '_myuserpro_nonce_' . $_POST['template'] . '_' . $_POST['unique_id'])) {
        die;
    }
    if (!isset($_POST) || $_POST['action'] != 'userpro_process_form') {
        die;
    }
    if (!userpro_is_logged_in() && $_POST['template'] == 'edit') {
        die;
    }
    extract($_POST);
    foreach ($_POST as $key => $val) {
        $key = explode('-', $key);
        $key = $key[0];
        $form[$key] = $val;
    }
    extract($form);
    /* form action */
    switch ($template) {
        /* publish */
        case 'publish':
            $output['error'] = '';
            if (!$post_title) {
                $output['error']['post_title'] = __('You must enter a post title.', 'userpro');
            }
            if (!$userpro_editor) {
                $output['error']['userpro_editor'] = __('You must enter some content.', 'userpro');
            }
            /*
            	publish post
            */
            if (empty($output['error'])) {
                $array = array('post_title' => $post_title, 'post_content' => @wp_kses($userpro_editor), 'post_author' => $user_id);
                if ($post_type) {
                    $array['post_type'] = $post_type;
                }
                if (userpro_is_admin($user_id)) {
                    $array['post_status'] = 'publish';
                    $post_id = wp_insert_post($array);
                    $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . sprintf(__('Your post has been published. You can view it %s.', 'userpro'), '<a href="' . get_permalink($post_id) . '">here</a>') . '</p></div>';
                } else {
                    // under review
                    $array['post_status'] = 'pending';
                    $post_id = wp_insert_post($array);
                    $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your post has been sent for review. It will be checked by our staff.', 'userpro') . '</p></div>';
                }
                /*
                	empty category first
                */
                wp_set_object_terms($post_id, NULL, 'category');
                /*
                	taxonomy
                	and category
                */
                if (isset($taxonomy) && isset($category)) {
                    $categories = explode(',', $category);
                    if (is_array($categories)) {
                        foreach ($categories as $cat) {
                            if (is_numeric($cat)) {
                                $cat = (int) $cat;
                            }
                            $cats[] = $cat;
                        }
                        wp_set_object_terms($post_id, $cats, $taxonomy);
                    } else {
                        if (is_numeric($categories)) {
                            $categories = (int) $categories;
                        }
                        wp_set_object_terms($post_id, $categories, $taxonomy);
                    }
                }
                /*
                	multiple taxonomy
                	category insertion
                */
                if (isset($post_categories)) {
                    $i = 0;
                    foreach ($post_categories as $cat) {
                        $i++;
                        $split = explode('#', $cat);
                        $tax = $split[1];
                        $id = $split[0];
                        $terms[$tax][] = $id;
                    }
                    if (is_array($terms)) {
                        foreach ($terms as $k => $arr) {
                            wp_set_object_terms($post_id, $terms[$k], $k, true);
                        }
                    }
                }
                /*
                	assign featured
                	image for post
                */
                if ($post_featured_image) {
                    $attach_id = $userpro->new_attachment($post_id, $post_featured_image);
                    $userpro->set_thumbnail($post_id, $attach_id);
                }
            }
            break;
            /* delete profile */
        /* delete profile */
        case 'delete':
            $output['error'] = '';
            $user = get_userdata($user_id);
            $user_roles = $user->roles;
            $user_role = array_shift($user_roles);
            if (!$confirmdelete) {
                $output['error']['confirmdelete'] = __('Nothing was deleted. You must choose yes to confirm deletion.', 'userpro');
            } elseif ($user_role == 'administrator') {
                $output['error']['confirmdelete'] = __('For security reasons, admin accounts cannot be deleted.', 'userpro');
            } elseif ($user->user_login == 'test') {
                $output['error']['confirmdelete'] = __('You cannot remove test accounts from frontend!', 'userpro');
            } else {
                require_once ABSPATH . 'wp-admin/includes/user.php';
                userpro_mail($user_id, 'accountdeleted');
                // Delete user
                if (is_multisite()) {
                    // Multisite: Deletes user's Posts and Links, then deletes from WP Users|Usermeta
                    // ONLY IF "Delete From Network" setting checked and user only belongs to this blog
                    wpmu_delete_user($user_id);
                } else {
                    // Deletes user's Posts and Links
                    // Multisite: Removes user from current blog
                    // Not Multisite: Deletes user from WP Users|Usermeta
                    wp_delete_user($user_id);
                }
                $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('This account has been deleted successfully.', 'userpro') . '</p></div>';
                $output['redirect_uri'] = home_url();
            }
            break;
            /* change pass */
        /* change pass */
        case 'change':
            $output['error'] = '';
            if (!$secretkey) {
                $output['error']['secretkey'] = __('You did not provide a secret key.', 'userpro');
            } elseif (strlen($secretkey) != 20) {
                $output['error']['secretkey'] = __('The secret key you entered is invalid.', 'userpro');
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_form_validation', $output['error'], $form);
            if (empty($output['error'])) {
                $users = get_users(array('meta_key' => 'userpro_secret_key', 'meta_value' => $secretkey, 'meta_compare' => '='));
                if (!$users[0]) {
                    $output['error']['secretkey'] = __('The secret key is invalid or expired.', 'userpro');
                } else {
                    $user_id = $users[0]->ID;
                    wp_update_user(array('ID' => $user_id, 'user_pass' => $user_pass));
                    delete_user_meta($user_id, 'userpro_secret_key');
                    add_action('userpro_pre_form_message', 'userpro_msg_login_after_passchange');
                    $shortcode = stripslashes($shortcode);
                    $modded = str_replace('template="change"', 'template="login"', $shortcode);
                    $output['template'] = do_shortcode($modded);
                }
            }
            break;
            /* send secret key */
        /* send secret key */
        case 'reset':
            $output['error'] = '';
            if (!$username_or_email) {
                $output['error']['username_or_email'] = __('You should provide your email or username.', 'userpro');
            } else {
                if (is_email($username_or_email)) {
                    $user = get_user_by_email($username_or_email);
                    $username_or_email = $user->user_login;
                }
                if (!username_exists($username_or_email)) {
                    $output['error']['username_or_email'] = __('There is not such user in our system.', 'userpro');
                } elseif (!$userpro->can_reset_pass($username_or_email)) {
                    $output['error']['username_or_email'] = __('Resetting admin password is not permitted!', 'userpro');
                }
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_form_validation', $output['error'], $form);
            /* email user with secret key and update
            			his user meta */
            if (empty($output['error'])) {
                $user = get_user_by('login', $username_or_email);
                $uniquekey = wp_generate_password(20, $include_standard_special_chars = false);
                update_user_meta($user->ID, 'userpro_secret_key', $uniquekey);
                userpro_mail($user->ID, 'secretkey', $uniquekey);
                add_action('userpro_pre_form_message', 'userpro_msg_secret_key_sent');
                $shortcode = stripslashes($shortcode);
                $modded = str_replace('template="reset"', 'template="change"', $shortcode);
                $output['template'] = do_shortcode($modded);
            }
            break;
            /* login */
        /* login */
        case 'login':
            $output['error'] = '';
            if (!$username_or_email) {
                $output['error']['username_or_email'] = __('You should provide your email or username.', 'userpro');
            }
            if (!$user_pass) {
                $output['error']['user_pass'] = __('You should provide your password.', 'userpro');
            }
            if (email_exists($username_or_email)) {
                $user = get_user_by('email', $username_or_email);
                $username_or_email = $user->user_login;
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_login_validation', $output['error'], $form);
            if (empty($output['error']) && $username_or_email && $user_pass) {
                $creds = array();
                $creds['user_login'] = $username_or_email;
                $creds['user_password'] = $user_pass;
                $creds['remember'] = true;
                $user = wp_signon($creds, false);
                if (is_wp_error($user)) {
                    if ($user->get_error_code() == 'invalid_username') {
                        $output['error']['username_or_email'] = __('Invalid email or username entered', 'userpro');
                    } elseif ($user->get_error_code() == 'incorrect_password') {
                        $output['error']['user_pass'] = __('The password you entered is incorrect', 'userpro');
                    }
                } else {
                    /* check the account is active first */
                    if ($userpro->is_pending($user->ID)) {
                        if (userpro_get_option('users_approve') === '2') {
                            $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your email is pending verification. Please activate your account.', 'userpro') . '</p></div>';
                        } else {
                            $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your account is currently being reviewed. Thanks for your patience.', 'userpro') . '</p></div>';
                        }
                        wp_logout();
                    } else {
                        /* a good login */
                        userpro_auto_login($user->user_login, true);
                        if (isset($force_redirect_uri) && !empty($force_redirect_uri)) {
                            $output['redirect_uri'] = 'refresh';
                        } else {
                            if (current_user_can('manage_options') && userpro_get_option('show_admin_after_login')) {
                                $output['redirect_uri'] = admin_url();
                            } else {
                                if (isset($redirect_uri) && !empty($redirect_uri)) {
                                    $output['redirect_uri'] = $redirect_uri;
                                } else {
                                    if (userpro_get_option('after_login') == 'no_redirect') {
                                        $output['redirect_uri'] = 'refresh';
                                    }
                                    if (userpro_get_option('after_login') == 'profile') {
                                        $output['redirect_uri'] = $userpro->permalink();
                                    }
                                }
                            }
                            /* hook the redirect URI */
                            $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
                        }
                        /* super redirection */
                        if (isset($global_redirect)) {
                            $output['redirect_uri'] = $global_redirect;
                        }
                    }
                    // active/pending
                }
            }
            break;
            /* editing */
        /* editing */
        case 'edit':
            if ($user_id != get_current_user_id() && !current_user_can('manage_options')) {
                die;
            }
            userpro_update_user_profile($user_id, $form, $action = 'ajax_save');
            if (userpro_get_option('notify_admin_profile_save') && !current_user_can('manage_options')) {
                userpro_mail($user_id, 'profileupdate', null, $form);
            }
            add_action('userpro_pre_form_message', 'userpro_msg_profile_saved');
            if ($_POST['up_username']) {
                set_query_var('up_username', $_POST['up_username']);
            }
            $shortcode = stripslashes($shortcode);
            $modded = $shortcode;
            $output['template'] = do_shortcode($modded);
            break;
            /* registering */
        /* registering */
        case 'register':
            $output['error'] = '';
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_register_validation', $output['error'], $form);
            if (empty($output['error']) && (isset($user_login) && isset($user_email) && isset($user_pass) || isset($user_login) && isset($user_email) || isset($user_email))) {
                if (isset($user_login)) {
                    $user_exists = username_exists($user_login);
                } else {
                    $user_exists = username_exists('the_cow_that_did_run_after_the_elephant');
                    $user_login = $user_email;
                }
                if (!isset($user_exists) and email_exists($user_email) == false) {
                    if (!isset($user_pass)) {
                        $user_pass = wp_generate_password($length = 12, $include_standard_special_chars = false);
                    }
                    /* not auto approved? */
                    if (userpro_get_option('users_approve') !== '1') {
                        /* require email validation */
                        if (userpro_get_option('users_approve') === '2') {
                            $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard', $approved = 0);
                            $userpro->pending_email_approve($user_id, $user_pass, $form);
                            add_action('userpro_pre_form_message', 'userpro_msg_activate_pending');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                        /* require admin validation */
                        if (userpro_get_option('users_approve') === '3') {
                            $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard', $approved = 0);
                            $userpro->pending_admin_approve($user_id, $user_pass, $form);
                            add_action('userpro_pre_form_message', 'userpro_msg_activate_pending_admin');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                    } else {
                        $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard');
                        /* auto login */
                        if (userpro_get_option('after_register_autologin')) {
                            $creds = array();
                            $creds['user_login'] = $user_login;
                            $creds['user_password'] = $user_pass;
                            $creds['remember'] = true;
                            $user = wp_signon($creds, false);
                            if (isset($user->user_login)) {
                                userpro_auto_login($user->user_login, true);
                            }
                            if ($redirect_uri) {
                                $output['redirect_uri'] = $redirect_uri;
                            } else {
                                if (userpro_get_option('after_register') == 'no_redirect') {
                                    $output['redirect_uri'] = 'refresh';
                                }
                                if (userpro_get_option('after_register') == 'profile') {
                                    $output['redirect_uri'] = $userpro->permalink();
                                }
                            }
                            /* hook the redirect URI */
                            $output['redirect_uri'] = apply_filters('userpro_register_redirect', $output['redirect_uri']);
                            /* manual login form */
                        } else {
                            add_action('userpro_pre_form_message', 'userpro_msg_login_after_reg');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                    }
                }
            }
            break;
    }
    $output = json_encode($output);
    if (is_array($output)) {
        print_r($output);
    } else {
        echo $output;
    }
    die;
}
function moderation_overview()
{
    global $wpdb, $wp_roles, $current_user, $user_id, $current_site;
    if (!is_moderator()) {
        die;
    }
    if (isset($_GET['updated'])) {
        ?>
<div id="message" class="updated fade"><p><?php 
        _e(urldecode($_GET['updatedmsg']), 'moderation');
        ?>
</p></div><?php 
    }
    echo '<div class="wrap">';
    if (!isset($_GET['action'])) {
        $_GET['action'] = '';
    }
    switch ($_GET['action']) {
        //---------------------------------------------------//
        default:
            $moderators_can_remove_users = get_site_option('moderators_can_remove_users', 'no');
            $moderators_can_remove_blogs = get_site_option('moderators_can_remove_blogs', 'no');
            $post_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "moderation_reports WHERE report_object_type = 'post' AND report_status = 'new'");
            $blog_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "moderation_reports WHERE report_object_type = 'blog' AND report_status = 'new'");
            $comment_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "moderation_reports WHERE report_object_type = 'comment' AND report_status = 'new'");
            ?>
            <h2><?php 
            _e('Moderation', 'moderation');
            ?>
</h2>
            <h3><?php 
            _e('Reports', 'moderation');
            ?>
</h3>
            <p>
            <strong><?php 
            _e('Posts', 'moderation');
            ?>
</strong>: <?php 
            echo $blog_count;
            ?>
<br />
            <strong><?php 
            _e('Comments', 'moderation');
            ?>
</strong>: <?php 
            echo $comment_count;
            ?>
<br />
            <strong><?php 
            _e('Blogs', 'moderation');
            ?>
</strong>: <?php 
            echo $blog_count;
            ?>
            </p>
            <h3><?php 
            _e('User Information', 'moderation');
            ?>
</h3>
            <form name="user_information" method="POST" action="admin.php?page=moderation&action=user_information">
                <table class="form-table">
                <tr valign="top">
                <th scope="row"><?php 
            _e('Username', 'moderation');
            ?>
</th>
                <td><input type="text" name="user_login" id="user_login" style="width: 95%" value="" />
                <br />
                <?php 
            //_e('')
            ?>
</td>
                </tr>
                <tr valign="top">
                <th scope="row"><?php 
            _e('User ID', 'moderation');
            ?>
</th>
                <td><input type="text" name="uid" id="uid" style="width: 95%" value="" />
                <br />
                <?php 
            //_e('')
            ?>
</td>
                </tr>
                <tr valign="top">
                <th scope="row"><?php 
            _e('User Email', 'moderation');
            ?>
</th>
                <td><input type="text" name="user_email" id="user_email" style="width: 95%" value="" />
                <br />
                <?php 
            //_e('')
            ?>
</td>
                </tr>
                </table>
            <p class="submit">
            <input class="button button-primary" type="submit" name="Submit" value="<?php 
            _e('Continue', 'moderation');
            ?>
" />
            </p>
            </form>
            <?php 
            if ($moderators_can_remove_users == 'yes') {
                ?>
            <h3><?php 
                _e('Remove User', 'moderation');
                ?>
</h3>
            <form name="remove_user" method="POST" action="admin.php?page=moderation&action=remove_user">
                <table class="form-table">
                <tr valign="top">
                <th scope="row"><?php 
                _e('Username', 'moderation');
                ?>
</th>
                <td><input type="text" name="user_login" id="user_login" style="width: 95%" value="" />
                <br /></td>
                </tr>
                <tr valign="top">
                <th scope="row"><?php 
                _e('User ID', 'moderation');
                ?>
</th>
                <td><input type="text" name="uid" id="uid" style="width: 95%" value="" />
                <br />
                <?php 
                //_e('')
                ?>
</td>
                </tr>
                <tr valign="top">
                <th scope="row"><?php 
                _e('User Email', 'moderation');
                ?>
</th>
                <td><input type="text" name="user_email" id="user_email" style="width: 95%" value="" />
                <br />
                <?php 
                //_e('')
                ?>
</td>
                </tr>
                </table>
            <p class="submit">
            <input class="button button-primary" type="submit" name="Submit" value="<?php 
                _e('Continue', 'moderation');
                ?>
" />
            </p>
            </form>
            <?php 
            }
            if ($moderators_can_remove_blogs == 'yes') {
                ?>
            <h3><?php 
                _e('Remove Blog', 'moderation');
                ?>
</h3>
            <form name="remove_blog" method="POST" action="admin.php?page=moderation&action=remove_blog">
                <table class="form-table">
                <tr valign="top">
                <th scope="row"><?php 
                _e('Blog ID', 'moderation');
                ?>
</th>
                <td><input type="text" name="bid" id="bid" style="width: 95%" value="" />
                <br />
                <?php 
                //_e('')
                ?>
</td>
                </tr>
                <tr valign="top">
                <th scope="row"><?php 
                _e('Blogname', 'moderation');
                ?>
</th>
                <td><input type="text" name="blog_name" id="blog_name" style="width: 95%" value="" />
                <br />
                <?php 
                //_e('')
                ?>
</td>
                </tr>
                </table>
            <p class="submit">
            <input class="button button-primary" type="submit" name="Submit" value="<?php 
                _e('Continue', 'moderation');
                ?>
" />
            </p>
            </form>
            <?php 
            }
            break;
            //---------------------------------------------------//
        //---------------------------------------------------//
        case "user_information":
            $uid = $_POST['uid'];
            if (empty($uid)) {
                $uid = $_GET['uid'];
            }
            $user_login = $_POST['user_login'];
            if (empty($user_login)) {
                $user_login = $_GET['user_login'];
            }
            $user_email = $_POST['user_email'];
            if (empty($user_email)) {
                $user_email = $_GET['user_email'];
            }
            if (!empty($user_login)) {
                $uid = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $user_login));
            }
            if (!empty($user_email)) {
                $uid = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . $wpdb->users . " WHERE user_email = %s", $user_email));
            }
            $user_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "users WHERE ID = '" . $uid . "'");
            if ($user_count > 0) {
                $user_login = $wpdb->get_var("SELECT user_login FROM " . $wpdb->base_prefix . "users WHERE ID = '" . $uid . "'");
                $warning_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "moderation_warnings WHERE warning_user_ID = '" . $uid . "'");
                $user_registered = $wpdb->get_var("SELECT user_registered FROM " . $wpdb->base_prefix . "users WHERE ID = '" . $uid . "'");
                $user_email = $wpdb->get_var("SELECT user_email FROM " . $wpdb->base_prefix . "users WHERE ID = '" . $uid . "'");
                $user_blogs = get_blogs_of_user($uid, true);
                ?>
				<h2><?php 
                _e('User Information', 'moderation');
                ?>
: <?php 
                echo $user_login;
                ?>
</h2>
				<form name="user_information" method="POST" action="admin.php?page=moderation">
				<p>
				<strong><?php 
                _e('Email', 'moderation');
                ?>
</strong>: <?php 
                echo $user_email;
                ?>
				<br />
				<strong><?php 
                _e('Registered', 'moderation');
                ?>
</strong>: <?php 
                echo mysql2date(get_option('date_format'), $user_registered);
                ?>
				<br />
				<strong><?php 
                _e('Warnings', 'moderation');
                ?>
</strong>: <?php 
                echo $warning_count;
                ?>
				<br />
				<strong><?php 
                _e('Post Archive', 'moderation');
                ?>
</strong>: <a href="admin.php?page=moderation-post-archive&object_type=post&uid=<?php 
                echo $uid;
                ?>
" style="text-decoration:none;" ><?php 
                _e('View', 'moderation');
                ?>
</a>
				<br />
				<strong><?php 
                _e('Blogs', 'moderation');
                ?>
</strong>:
                <?php 
                if (is_array($user_blogs)) {
                    echo '<br />';
                    foreach ((array) $user_blogs as $key => $val) {
                        $path = $val->path == '/' ? '' : $val->path;
                        echo '<a href="http://' . $val->domain . $path . '">' . str_replace('.' . $current_site->domain, '', $val->domain . $path) . '</a>';
                        echo '<br />';
                    }
                } else {
                    echo __('None', 'moderation');
                }
                ?>
				</p>
				<p class="submit">
				<input class="button button-primary" type="submit" name="Submit" value="<?php 
                _e('Back', 'moderation');
                ?>
" />
				</p>
				</form>
				<?php 
            } else {
                ?>
				<h2><?php 
                _e('Error', 'moderation');
                ?>
</h2>
                <?php 
                echo '<p>' . __('User not found.', 'moderation') . '</p>';
            }
            break;
            //---------------------------------------------------//
        //---------------------------------------------------//
        case "remove_user":
            $uid = $_POST['uid'];
            if (empty($uid)) {
                $uid = $_GET['uid'];
            }
            $user_login = $_POST['user_login'];
            if (empty($user_login)) {
                $user_login = $_GET['user_login'];
            }
            $user_email = $_POST['user_email'];
            if (empty($user_email)) {
                $user_email = $_GET['user_email'];
            }
            if (!empty($user_login)) {
                $uid = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $user_login));
            }
            if (!empty($user_email)) {
                $uid = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . $wpdb->users . " WHERE user_email = %s", $user_email));
            }
            $user_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "users WHERE ID = '" . $uid . "'");
            if ($user_count > 0) {
                $user_login = $wpdb->get_var("SELECT user_login FROM " . $wpdb->base_prefix . "users WHERE ID = '" . $uid . "'");
                if (!is_moderator($user_login)) {
                    ?>
					<h2><?php 
                    _e('Remove User', 'moderation');
                    ?>
: <?php 
                    echo $user_login;
                    ?>
</h2>
					<form name="remove_user" method="POST" action="admin.php?page=moderation&action=remove_user_process&uid=<?php 
                    echo $uid;
                    ?>
">
						<table class="form-table">
						<tr valign="top">
						<th scope="row"><?php 
                    _e('Are you sure?', 'moderation');
                    ?>
</th>
						<td>
						<select name="remove_user" id="remove_user">
								<option value="yes"><?php 
                    _e('Yes', 'moderation');
                    ?>
</option>
								<option value="no" selected="selected" ><?php 
                    _e('No', 'moderation');
                    ?>
</option>
						</select>
						<br /><?php 
                    //_e('')
                    ?>
</td>
						</tr>
						</table>
					<p class="submit">
					<input class="button button-primary" type="submit" name="Submit" value="<?php 
                    _e('Continue', 'moderation');
                    ?>
" />
					</p>
					</form>
					<?php 
                } else {
                    ?>
					<h2><?php 
                    _e('Error', 'moderation');
                    ?>
</h2>
					<?php 
                    echo '<p>' . __('You cannot remove a moderator or site admin.', 'moderation') . '</p>';
                }
            } else {
                ?>
				<h2><?php 
                _e('Error', 'moderation');
                ?>
</h2>
                <?php 
                echo '<p>' . __('User not found.', 'moderation') . '</p>';
            }
            break;
            //---------------------------------------------------//
        //---------------------------------------------------//
        case "remove_user_process":
            if ($_POST['remove_user'] == 'no') {
                echo "\n\t\t\t\t<SCRIPT LANGUAGE='JavaScript'>\n\t\t\t\twindow.location='admin.php?page=moderation';\n\t\t\t\t</script>\n\t\t\t\t";
            } else {
                wpmu_delete_user($_GET['uid']);
                echo "\n\t\t\t\t<SCRIPT LANGUAGE='JavaScript'>\n\t\t\t\twindow.location='admin.php?page=moderation&updated=true&updatedmsg=" . urlencode('User removed') . "';\n\t\t\t\t</script>\n\t\t\t\t";
            }
            break;
            //---------------------------------------------------//
        //---------------------------------------------------//
        case "remove_blog":
            $bid = $_POST['bid'];
            if (empty($bid)) {
                $bid = $_GET['bid'];
            }
            $blog_name = $_POST['blog_name'];
            if (empty($blog_name)) {
                $blog_name = $_GET['blog_name'];
            }
            if (!empty($blog_name)) {
                if (VHOST == 'yes') {
                    $bid = $wpdb->get_var("SELECT blog_id FROM " . $wpdb->blogs . " WHERE domain = '" . $blog_name . "." . $current_site->domains . "'");
                } else {
                    $bid = $wpdb->get_var($wpdb->prepare("SELECT blog_id FROM " . $wpdb->blogs . " WHERE path = %s", $current_site->path . $blog_name . "/"));
                }
            }
            $blog_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "blogs WHERE blog_id = '" . $bid . "'");
            if ($blog_count > 0) {
                $blog_details = get_blog_details($bid);
                if ($bid != '1') {
                    ?>
					<h2><?php 
                    _e('Remove Blog', 'moderation');
                    ?>
: <a href="<?php 
                    echo $blog_details->siteurl;
                    ?>
" style="text-decoration:none;"><?php 
                    echo $blog_details->blogname;
                    ?>
</a></h2>
					<form name="remove_blog" method="POST" action="admin.php?page=moderation&action=remove_blog_process&bid=<?php 
                    echo $bid;
                    ?>
">
						<table class="form-table">
						<tr valign="top">
						<th scope="row"><?php 
                    _e('Are you sure?', 'moderation');
                    ?>
</th>
						<td>
						<select name="remove_blog" id="remove_blog">
								<option value="yes"><?php 
                    _e('Yes', 'moderation');
                    ?>
</option>
								<option value="no" selected="selected" ><?php 
                    _e('No', 'moderation');
                    ?>
</option>
						</select>
						<br /><?php 
                    //_e('')
                    ?>
</td>
						</tr>
						</table>
					<p class="submit">
					<input class="button button-primary" type="submit" name="Submit" value="<?php 
                    _e('Continue', 'moderation');
                    ?>
" />
					</p>
					</form>
					<?php 
                } else {
                    ?>
					<h2><?php 
                    _e('Error', 'moderation');
                    ?>
</h2>
					<?php 
                    echo '<p>' . __('You cannot remove the main blog.', 'moderation') . '</p>';
                }
            } else {
                ?>
				<h2><?php 
                _e('Error', 'moderation');
                ?>
</h2>
                <?php 
                echo '<p>' . __('Blog not found.', 'moderation') . '</p>';
            }
            break;
            //---------------------------------------------------//
        //---------------------------------------------------//
        case "remove_blog_process":
            if ($_POST['remove_blog'] == 'no') {
                echo "\n\t\t\t\t<SCRIPT LANGUAGE='JavaScript'>\n\t\t\t\twindow.location='admin.php?page=moderation';\n\t\t\t\t</script>\n\t\t\t\t";
            } else {
                wpmu_delete_blog($_GET['bid']);
                echo "\n\t\t\t\t<SCRIPT LANGUAGE='JavaScript'>\n\t\t\t\twindow.location='admin.php?page=moderation&updated=true&updatedmsg=" . urlencode('Blog removed') . "';\n\t\t\t\t</script>\n\t\t\t\t";
            }
            break;
            //---------------------------------------------------//
    }
    echo '</div>';
}