Skip to content

peter-bosch/discourse-membership-id-checker

Repository files navigation

Discourse Membership Validator

A Discourse plugin that validates user membership numbers against an uploaded list and suspends users whose numbers are not found.

Features

  • Admin panel at /admin/plugins/membership-validator with a textarea to paste membership numbers (one per line)
  • Preview mode — see exactly who will be affected before taking action, broken down into:
    • Valid — membership number found in the list
    • Invalid — membership number NOT in the list (will be suspended)
    • Exempt — user is on the exempt list, won't be touched regardless
    • No number — user has no membership number set (not affected)
  • Exempt user list — add specific users (e.g. system accounts, generic posting accounts) who should never be suspended by this plugin
  • Confirmation step — suspensions only happen after explicit admin confirmation
  • Staff action logging — all suspensions are logged via Discourse's built-in staff action logger
  • System messages — suspended users receive a system message explaining why

Requirements

  • Discourse 2.7.0+
  • A User Custom Field named exactly Membership Number (create this in Admin → Customize → User Fields)

Installation

Add to your app.yml containers config:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/peter-bosch/discourse-membership-id-checker.git

Then rebuild: ./launcher rebuild app

Configuration

After installation, go to Admin → Settings and search for membership_validator:

Setting Default Description
membership_validator_enabled false Master on/off switch
membership_validator_suspension_reason "Your membership number was not found…" Reason shown to suspended users
membership_validator_suspend_days 365 Duration of suspension in days

Usage

  1. Enable the plugin in Admin → Settings
  2. Create the custom field "Membership Number" in Admin → Customize → User Fields (if it doesn't exist)
  3. Navigate to Admin → Plugins → Membership Validator
  4. Paste your current membership numbers into the textarea (one per line, or comma/semicolon separated)
  5. Click Preview Changes to see the breakdown
  6. Review the list of users that will be suspended
  7. Click Suspend Flagged Users and confirm

Managing Exempt Users

Scroll to the "Exempt Users" section at the bottom of the admin page. Type a username and click "Add exempt user". These users will never be suspended by this plugin, regardless of their membership number status.

Common use cases for exemptions:

  • System/bot accounts
  • Generic accounts used for site-wide announcements
  • Staff accounts that don't have membership numbers

How It Works

  1. The plugin reads UserCustomField records where name = "Membership Number"
  2. It compares each user's value against the pasted list
  3. Admin users and already-suspended users are always skipped
  4. Exempt users are always skipped
  5. Matching is exact (whitespace-trimmed) — the membership number must appear exactly as entered
  6. Suspensions use Discourse's built-in suspension system (user.suspended_till)

Important Notes

  • Admin users are never suspended by this plugin
  • Already-suspended users are skipped (no double-suspension)
  • Users without a membership number are not affected — only users who have a number that doesn't match are suspended
  • Suspensions can be manually reversed per-user through the normal Discourse admin interface
  • The plugin does NOT automatically unsuspend users if their number later appears in a new list — that must be done manually

Development

# Clone inside your Discourse dev plugins directory
cd /path/to/discourse/plugins
git clone https://github.com/peter-bosch/discourse-membership-id-checker.git

# Run migrations
cd /path/to/discourse
RAILS_ENV=development rake db:migrate

# Start Discourse
bin/ember-cli -u  # frontend
rails s           # backend

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors