Need Help with Limiting User Posts by Category and Time Frame

Hi, @pfaffman , happy holidays and thanks for reply!

I tried to create a flow chart to make it clear:

flowchart TB
    A0(User attempts to create a new topic in Category A or B) --> A1{Is user in<br>exempt group--Admin, Mod,TL3, TL4,Subscribers?}
    A1 -- No --> B1(Check user's last topic in Categories A, B, or C,<br>including hidden or deleted records)
    A1 -- Yes --> Z1(Allow posting)

    B1 --> B2{Was that last topic<br>created within 14 days?}
    B2 -- Yes --> C1(Block post + show error,<br>display cooldown,<br>link to rules)
    C1 --> E1(Save draft +<br>disable submit button) ---> End(End)
    B2 -- No --> D1(Allow post)

    D1 --> End(End)
    Z1 --> End(End)
And I also try to create a simple spec to help clarify
```mermaid
flowchart TB
    A0(User attempts to create a new topic in Category A or B) --> A1{Is user in<br>exempt group--Admin, Mod,TL3, TL4,Subscribers?}
    A1 -- No --> B1(Check user's last topic in Categories A, B, or C,<br>including hidden or deleted records)
    A1 -- Yes --> Z1(Allow posting)

    B1 --> B2{Was that last topic<br>created within 14 days?}
    B2 -- Yes --> C1(Block post + show error,<br>display cooldown,<br>link to rules)
    C1 --> E1(Save draft +<br>disable submit button) ---> End(End)
    B2 -- No --> D1(Allow post)

    D1 --> End(End)
    Z1 --> End(End)

Flow Explanation

  1. A0: A user initiates creating a new topic in Category A or B.

  2. A1: The system checks whether the user belongs to any exempt group:
    • Administrators
    • Moderators
    • Trust Level 3 (TL3)
    • Trust Level 4 (TL4)
    • A custom “Subscribers” group
    • If Yes, skip the cooldown check and immediately allow posting (Z1).
    • If No, proceed to B1.

  3. B1: The system retrieves the user’s last created topic in Categories A, B, or C. This lookup must include:
    • Soft-deleted topics (not permanently removed from the database).
    • Topics moved to hidden or compliance categories (e.g., Category C).

  4. B2: The system checks if the creation date of that last topic is within the past 14 days.
    • Yes → Continue to C1 (the post is blocked).
    • No → Proceed to D1 (allow the post).

  5. C1: The system shows an error message informing the user they are still under cooldown. The message should include:
    • A simplified statement that they cannot post yet.
    • The remaining time in days and hours (no minutes).
    • A link to the community rules page (provided below).

  6. E1: After showing the error, the user’s content is automatically saved as a draft, and the “Submit” or “Create Topic” button is disabled.

  7. D1: If more than 14 days have passed since the user’s last topic, the system allows the new topic to be posted.

  8. Z1: The user is in an exempt group, so they can post without restriction.

2. Detailed Specification

2.1 Restricted vs. Exempt Groups

• Restricted Groups:
• Any users not in the following exempt groups (commonly TL0, TL1, TL2).
• Exempt Groups:

  1. Administrators
  2. Moderators
  3. Trust Level 3 (TL3)
  4. Trust Level 4 (TL4)
  5. Subscribers (a custom group)

These exempt groups skip the 14-day check altogether.

2.2 Categories in Scope

• New Topic Attempt:

• Triggered when a user (in a restricted group) tries to create a new topic in Category A or B.

• Last Topic Check:

• The system checks the user’s last created topic in Categories A, B, or C (where C is the “hidden” or “compliance” category).

Note: Category C is included to capture situations where a user’s topic is moved for deletion/hiding/compliance. If the user created a topic in Category C within the last 14 days, it also counts towards the cooldown.

2.3 14-Day Cooldown Logic

• If the user’s most recent topic (in A/B/C) was created within 14 days, block new topic creation in A or B.

• If more than 14 days have passed, allow it.

Time Calculation

• Display the remaining time in days and hours (e.g., “3 days 12 hours remaining”).
• No need to show minutes or seconds.

2.4 Blocking and Draft Saving

• Blocking Behavior:
• When the user is blocked, show an error message (C1).
• The system automatically saves the user’s content as a draft.
• The “Submit” button becomes disabled so the user cannot proceed.
• Sample Error Message (simplified):

Sorry, you can’t create a new topic in this category yet.
Your last topic was posted less than 14 days ago,
and you have {X days and Y hours} left before you can post again.
For more details, see our community rules:
https://community.lezismore.org/t/topic/26/2

2.5 Future Flexibility

  1. Additional Categories:

• Currently only A, B, and C are configured.

• If you need to add or remove categories from this cooldown in the future, ensure the system or plugin can be extended without major code changes.

  1. Different Time Periods:

• The 14-day period could be configurable in the plugin’s settings (in case you want 7 days, 30 days, etc.).

  1. Dynamic Group Assignments:

• Additional or fewer exempt groups (e.g., if you add “Subscribers” or remove it) should be supported.

3. Summary

  1. Restricted Groups (TL0, TL1, TL2, or any user not in an exempt group) are subject to a 14-day cooldown before creating another topic in Categories A or B.

  2. Exempt Groups (Admin, Moderator, TL3, TL4, “Subscribers”) can post without restriction.

  3. The system checks the most recent topic creation in Categories A, B, or C (including soft-deleted or hidden). If it was created within 14 days, the new topic is blocked.

  4. Error Message: Displays the time remaining in days/hours and links to the community rules at:

• https://community.lezismore.org/t/topic/26/2

  1. Draft: When blocked, the user’s post is saved as a draft, and the submit button is disabled.

  2. This specification can be extended to additional categories or different timeframes in the future.

I’d appreciate any suggestions!