Wrong reason shown why moderator user can't be deleted

AI-generated summary

The discussion addresses a bug where moderators are shown the incorrect reason for why they cannot be deleted. Moin reports that the UI displays “Admins can’t be deleted” for non-admin moderators, which is misleading since moderators can be deleted. Lilly confirms the issue on a test site. tobiaseigen clarifies that the bug is not about deletion permissions but about the wrong reason being displayed to moderators. Moin and tobiaseigen discuss the confusion, and zogstrip notes the fix aims to align the UI with the backend logic.

In FIX: Correct user deletion wording by hlashbrooke · Pull Request #34680 · discourse/discourse · GitHub “and moderators” was removed from the note explaining why a user can’t be deleted:

delete_forbidden_because_staff: “Admins and moderators can’t be deleted.”

I understand that this is helpful because moderators can be deleted. But I have the impression that something was overlooked in this adjustment, which confused me today.
My user is a moderator, but not an admin, and still the note said “Admins can’t be deleted”.


…

After checking the code, I think I found why this happens: If a user cannot be deleted, there are two possible reasons:

  1. The user is an admin.
  2. The user has posts older than configured.

The real reason why I couldn’t delete my moderator user was [2], but the reason shown is [1], because while moderators were removed from the text of the warning, the code still checked for staff instead of admin.

3 Likes

yea I can repro this on my hosted test site as well. as soon as I delete the posts for my test moderator account, the “admins can’t be deleted” message is replaced by the delete button. thanks for reporting Moin :slight_smile:

1 Like

To clarify further.. a user who is not moderator can’t be deleted and the reason shown is below. The bug is that the wrong reason is shown when the user is a moderator.

Users can’t be deleted if they have posts. Delete all posts before trying to delete a user. (Posts older than 365 days old can’t be deleted.)

Admins see the wrong reason too. It’s not about who looks at the user’s admin page, but what status the user has that you are looking at.

Yeah that’s what I meant but got the sentence structure wrong! :rofl: I think I fixed it now.

All of this said.. I wonder why it is possible to delete moderators. I think it makes sense to demote users before deleting them and have always done that, and not questioned the UI.

Thank you. I was concerned that your clarification would lead to misunderstandings, even though I thought the title described the problem quite well.

1 Like

This should hopefully make the UI consistent with the back-end

https://github.com/discourse/discourse/pull/35496

3 Likes