diff --git a/public/src/admin/manage/users.js b/public/src/admin/manage/users.js
index cc39889807..7138bb01b9 100644
--- a/public/src/admin/manage/users.js
+++ b/public/src/admin/manage/users.js
@@ -195,7 +195,7 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
return;
}
- bootbox.confirm('Warning!
Do you really want to delete user(s)?
This action is not reversable, all user data and content will be erased!', function(confirm) {
+ bootbox.confirm('Warning!
Do you really want to delete user(s)?
This action is not reversable, only the user account will be deleted, their posts and topics will not be deleled!', function(confirm) {
if (confirm) {
socket.emit('admin.user.deleteUsers', uids, function(err) {
if (err) {
@@ -210,6 +210,26 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
});
});
+ $('.delete-user-and-content').on('click', function() {
+ var uids = getSelectedUids();
+ if (!uids.length) {
+ return;
+ }
+ bootbox.confirm('Warning!
Do you really want to delete user(s) and their content?
This action is not reversable, all user data and content will be erased!', function(confirm) {
+ if (confirm) {
+ socket.emit('admin.user.deleteUsersAndContent', uids, function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+
+ app.alertSuccess('User(s) Deleted!');
+ removeSelected();
+ unselectAll();
+ });
+ }
+ });
+ });
+
function handleUserCreate() {
var errorEl = $('#create-modal-error');
$('#createUser').on('click', function() {
diff --git a/src/socket.io/admin/user.js b/src/socket.io/admin/user.js
index ed7b4b378d..3fd69a8d10 100644
--- a/src/socket.io/admin/user.js
+++ b/src/socket.io/admin/user.js
@@ -142,7 +142,19 @@ User.sendPasswordResetEmail = function(socket, uids, callback) {
};
User.deleteUsers = function(socket, uids, callback) {
- if(!Array.isArray(uids)) {
+ deleteUsers(socket, uids, function(uid, next) {
+ user.deleteAccount(uid, next);
+ }, callback);
+};
+
+User.deleteUsersAndContent = function(socket, uids, callback) {
+ deleteUsers(socket, uids, function(uid, next) {
+ user.delete(socket.uid, uid, next);
+ }, callback);
+};
+
+function deleteUsers(socket, uids, method, callback) {
+ if (!Array.isArray(uids)) {
return callback(new Error('[[error:invalid-data]]'));
}
@@ -156,7 +168,7 @@ User.deleteUsers = function(socket, uids, callback) {
return next(new Error('[[error:cant-delete-other-admins]]'));
}
- user.delete(socket.uid, uid, next);
+ method(uid, next);
},
function (next) {
events.log({
@@ -169,7 +181,7 @@ User.deleteUsers = function(socket, uids, callback) {
}
], next);
}, callback);
-};
+}
User.search = function(socket, data, callback) {
user.search({query: data.query, searchBy: data.searchBy, uid: socket.uid}, function(err, searchData) {
diff --git a/src/views/admin/manage/users.tpl b/src/views/admin/manage/users.tpl
index 6683f6e887..d6dd8c5a25 100644
--- a/src/views/admin/manage/users.tpl
+++ b/src/views/admin/manage/users.tpl
@@ -30,6 +30,7 @@