How to prevent user deletion if it has posts

AI-generated summary

A user, carlosjcabello, is inquiring about the user deletion process, as they were able to delete a user with posts despite the expectation that this should not be possible. Johani clarifies that the ability to delete a user with posts depends on the age of the oldest post, which is determined by the delete_user_max_post_age site setting. By default, this setting is 60 days, meaning users with posts older than 60 days cannot be deleted without first deleting their posts. If the oldest post is younger than the set age limit, the user can be deleted, and all their posts will be automatically deleted. The delete_user_max_post_age setting can be adjusted to fit specific needs. carlosjcabello thanks Johani for the clarification.

Hi,

I’ve created this topic because I don’t fully understand how the user deletion process works.

I thought that it was not possible to delete a user if it had posts. It seems there is even an informative message for this on the user page in the Admin panel:

Users can’t be deleted if they have posts. Delete all posts before trying to delete a user.

See for instance these related topics that mention that message:

However, I don’t see it in my forum (see image below) and I was able to delete a user with posts via the “Delete User” button as a moderator.

Therefore, I would like to know how I can prevent staff members from deleting users with posts and get the informative message displayed. Is there any setting that I missed?

Thanks,
Carlos

Hey Carlos :wave:

This is correct, but it’s a little bit more nuanced than it seems.

You cannot delete users who have posts older than the limit set in the delete_user_max_post_age site setting on your site. That setting defaults to 60 days.

So it works like this:

If the oldest post the user you’re trying to delete is 59 days old, you can delete that user. Deleting them will automatically delete all of their posts.

If it’s older than 60 days, you cannot delete the user. You would have to delete all of their posts first before deleting them. You actually won’t even see the delete button. You’ll see the message you mentioned in your post

Users can’t be deleted if they have posts. Delete all posts before trying to delete a user.

until you delete all of their posts.

If the defaults don’t work for you - like, say for example, you don’t want your moderators to delete anyone with posts older than 10 days - then you can change the delete_user_max_post_age setting on your site to match your needs.

Thank you for the information and for clarifying this matter :slight_smile: