/**
 * 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 nxtmu_delete_user() Deletes a user from the system on multisite installs.
 * @uses nxt_delete_user() Deletes a user from the system on singlesite installs.
 */
function bp_core_delete_account($user_id = 0)
{
    global $bp, $nxt_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 ($nxt_version >= '3.0') {
            require ABSPATH . '/nxt-admin/includes/ms.php';
        } else {
            require ABSPATH . '/nxt-admin/includes/mu.php';
        }
        require ABSPATH . '/nxt-admin/includes/user.php';
        return nxtmu_delete_user($user_id);
        // Single site user deletion
    } else {
        require ABSPATH . '/nxt-admin/includes/user.php';
        return nxt_delete_user($user_id);
    }
}
Example #2
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;
                    }
                    nxtmu_delete_user($id);
                    $i++;
                }
            }
            if ($i == 1) {
                $deletefunction = 'delete';
            } else {
                $deletefunction = 'all_delete';
            }
            nxt_redirect(add_query_arg(array('updated' => 'true', 'action' => $deletefunction), network_admin_url('users.php')));
            exit;
            break;
    }
}
$nxt_list_table = _get_list_table('nxt_MS_Users_List_Table');
$pagenum = $nxt_list_table->get_pagenum();