Skip to content

26bz/WHMCS-Discord-Client-Verification

WHMCS Discord Client Verification Addon

A professional WHMCS addon module that integrates with Discord to automatically verify clients and assign roles based on their account status.

Features

  • OAuth2 Discord Authentication: Secure Discord verification using OAuth2 flow
  • Automatic Role Assignment: Assigns different roles based on active WHMCS products
  • Automatic Guild Joining: Adds users to your Discord server when they verify
  • Real-time Updates: Hooks into WHMCS events for instant role synchronization
  • Daily Synchronization: Cron job ensures roles stay in sync
  • Environment Variable Support: Secure credential management
  • Comprehensive Logging: Full activity and API call logging for debugging

Installation

  1. Upload Files: Copy the entire addon directory to your WHMCS installation:

    /path/to/whmcs/modules/addons/discord_verification/
    
  2. Activate Module:

    • Go to Setup → Addon Modules in WHMCS Admin
    • Find "Discord Client Verification" and click Activate
  3. Configure Module:

    • Click Configure next to the activated module
    • Fill in your Discord application credentials:
      • Discord Client ID: Your Discord app's client ID
      • Discord Secret ID: Your Discord app's client secret
      • Discord Bot Token: Your Discord bot token
      • Discord Guild ID: Your Discord server ID
      • Active Role ID: Role ID for clients with active products
      • Default Role ID: Role ID for verified clients without active products
      • Auto Join Server: Enable to automatically add users to your Discord server when they verify

Discord Application Setup

  1. Create Discord Application:

  2. Create Bot:

    • In your application, go to the Bot section
    • Create a bot and copy the Bot Token
    • Enable required bot permissions: Manage Roles
  3. Set OAuth2 Redirect URI:

    • In OAuth2 → General, add redirect URI:
    https://yourdomain.com/index.php?m=discord_verification
    
  4. Configure OAuth2 Scopes:

    • In OAuth2 → URL Generator, select the following scopes:
      • identify - Required for basic user information
      • email - Optional but recommended
      • guilds.join - Required for automatic server joining
  5. Invite Bot to Server:

    • Use OAuth2 URL Generator with bot scope and the following permissions:
      • Manage Roles - Required for role assignment
      • Manage Guild - Required for auto-joining users to the server
    • Ensure bot role is higher than roles it needs to assign

Environment Variables (Optional)

For enhanced security, you can use environment variables:

export DISCORD_CLIENT_ID="your_client_id"
export DISCORD_SECRET_ID="your_client_secret"
export DISCORD_BOT_TOKEN="your_bot_token"

These will override module configuration settings.

Usage

  1. Client Verification:

    • Clients visit: https://yourdomain.com/index.php?m=discord_verification
    • They authenticate with Discord and get verified
    • Roles are automatically assigned based on account status
  2. Admin Management:

    • Go to Setup → Addon Modules → Discord Client Verification
    • View statistics: total verified users, active vs default role counts
    • See all verified users with their Discord info and role status
    • Sync All Users: Manually trigger role synchronization for all users
    • Individual Actions: Sync or remove Discord associations per user
  3. Client Area Widget:

    • Optional sidebar widget showing Discord verification status
    • Shows "Active Member", "Verified", or "Not Verified" badges
    • Quick access buttons to verify or manage Discord connection
    • Can be enabled/disabled in addon configuration
  4. Automatic Role Management:

    • Roles update when services are activated/suspended/terminated
    • Daily cron job ensures synchronization
    • Manual role updates via admin interface or activity log

Troubleshooting

  1. Check WHMCS Activity Log: All operations are logged for debugging
  2. Verify Discord Permissions: Ensure bot has Manage Roles permission
  3. Check Role Hierarchy: Bot role must be higher than assigned roles
  4. Validate OAuth2 Settings: Ensure redirect URI matches exactly

Requirements

  • WHMCS 7.0+
  • PHP 7+
  • cURL extension
  • Valid Discord application with bot

License

This project is licensed under the GNU General Public License v3.0 (GPLv3).

  • You may use, modify, and redistribute this module freely.
  • Any distributed modifications must remain under GPLv3.
  • Commercial resale of closed-source versions is not allowed.

Full license text is in the LICENSE file.

Contact

About

Discord Role Assignment for WHMCS Clients

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project