fof / open-collective
Open Collective integration for your Flarum forum
Fund package maintenance!
Website
Installs: 1 248
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 2
Open Issues: 0
Type:flarum-extension
pkg:composer/fof/open-collective
Requires
- flarum/core: ^2.0.0
- guzzlehttp/guzzle: ^7.1
Requires (Dev)
- flarum/phpstan: ^2.0.0
- flarum/testing: ^2.0.0
- dev-master
- 2.x-dev
- 2.0.0-beta.1
- 1.x-dev
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.3.0
- 0.2.0
- 0.1.2
- 0.1.1
- 0.1.0
- dev-im/2.x
- dev-im/recurring
- dev-im/maintenance
- dev-dependabot/npm_and_yarn/js/babel/runtime-7.28.4
- dev-dependabot/npm_and_yarn/js/babel/helpers-7.28.4
- dev-dependabot/npm_and_yarn/js/cross-spawn-7.0.6
- dev-dev/1.0
This package is auto-updated.
Last update: 2025-12-24 16:41:57 UTC
README
A Flarum extension that automatically synchronizes your Open Collective backers with Flarum user groups.
Features
- π Automatic Synchronization: Hourly checks for new and removed backers
- π₯ Smart User Matching: Matches backers via email addresses
- π― Dual Group Support: Separate groups for recurring and one-time backers
- π Status-Based Categorization: Automatically moves past recurring backers to one-time group
- π Safe Group Management: Only manages users it adds, won't interfere with manually assigned groups
- π Detailed Logging: Tracks all changes in dedicated log files
- π§ͺ Dry-Run Mode: Preview changes before applying them
- π Verbose Output: Detailed information about the synchronization process
How It Works
This extension connects your Open Collective account with your Flarum forum by:
- Fetching Backers: Queries Open Collective's GraphQL API to retrieve your current backers (active recurring, cancelled recurring, and one-time contributors)
- Categorizing Backers: Separates backers into two groups:
- Recurring backers: Users with active monthly or yearly subscriptions
- One-time backers: Users who made one-time contributions or whose recurring subscription has ended
- Matching Users: Identifies Flarum users by matching email addresses from Open Collective backers with Flarum user emails
- Managing Groups: Automatically adds backers to designated Flarum groups and removes users who are no longer backers
- Handling Transitions: When a recurring backer's subscription ends, they are automatically moved to the one-time backers group
- Tracking Changes: Logs all additions, removals, and transitions to help you monitor the process
Installation
Install with composer:
composer require fof/open-collective:"*"
php flarum migrate
php flarum cache:clear
Required: Flarum Scheduler
This extension requires Flarum's scheduler to be set up and running. The extension will automatically check for backer updates every hour.
Add this cron job to your server:
* * * * * cd /path-to-your-project && php flarum schedule:run >> /dev/null 2>&1
Configuration
After installation, configure the extension in your Flarum admin panel:
1. Create an Open Collective Personal Token
- Go to Open Collective Applications
- Create a new Personal Token
- Copy the token (you won't be able to see it again)
Legacy API Keys: If you have an existing legacy API key, you can continue using it by enabling "Use Legacy Application API Key" in the settings. However, it's recommended to migrate to a Personal Token.
2. Configure the Extension
In your Flarum admin panel, navigate to the Open Collective extension settings:
- Personal Token (or API Key if using legacy): Paste your Open Collective token
- Collective Slug: Enter your collective slug (e.g., if your collective is at
opencollective.com/your-collective, enteryour-collective) - Recurring Backers Group: Select which Flarum group to assign to recurring backers (required)
- One-Time Backers Group: Optionally select a group for one-time backers and past recurring backers (optional)
Note: If you only configure the recurring backers group, all backers (both recurring and one-time) will be added to that single group. If you configure both groups, the extension will automatically categorize backers based on their subscription status.
Save the settings, and the extension will start syncing on the next scheduled run.
Usage
Once configured, the extension runs automatically every hour. You can also manually trigger an update:
php flarum fof:open-collective:update
Command Options
Dry-Run Mode
Preview what changes would be made without actually applying them:
php flarum fof:open-collective:update --dry-run
This is useful for testing your configuration before letting the extension make real changes to your groups.
Verbose Output
Get detailed information about the synchronization process:
php flarum fof:open-collective:update -v
Verbose mode shows:
- Configuration details (API type, collective slug, target groups)
- Total number of backers and breakdown by type (recurring vs one-time)
- All backers from Open Collective with their emails and type
- Matched Flarum users for each group
- Unmatched backers who couldn't be linked to Flarum accounts
- Summary of users staying, being added, removed, and moved between groups
Combine both options for detailed preview:
php flarum fof:open-collective:update --dry-run -v
Viewing Logs
Check the synchronization logs:
tail -f storage/logs/fof-open-collective.log
Log output includes:
- Number of backers found on Open Collective
- Number of backers matched to Flarum users
- Users added to the group (with
+ #userID username) - Users removed from the group (with
- #userID username) - Any API errors or configuration issues
How User Matching Works
The extension matches Open Collective backers to Flarum users by comparing email addresses. For a backer to be matched:
- The backer must have a public email address on their Open Collective profile
- A Flarum user must exist with that same email address
- The Flarum user's email must be confirmed
Important Notes
- Safe Group Management: The extension only removes the group from users it previously added. It won't affect users who were manually added to the group.
- Email Matching: Users must have the same email address as their Open Collective account.
- Backer Categorization:
- Users with active monthly or yearly subscriptions are placed in the recurring backers group
- Users who made one-time contributions or whose subscription has ended are placed in the one-time backers group
- When a recurring subscription ends, the user is automatically moved to the one-time group (if configured)
- Rate Limits: The Open Collective API has rate limits. The extension checks once per hour to stay well within these limits.
- Email Privacy: Some backers may have private email addresses on Open Collective. These backers cannot be matched to Flarum users automatically.
For Developers: Event System
This extension dispatches events when backers are added or removed, allowing other extensions to react to these changes.
Available Events
FoF\OpenCollective\Event\BackerAdded
Dispatched when a user is added to the backers group.
Properties:
$user(Flarum\User\User) - The Flarum user who was added$backerData(object|null) - Open Collective backer data including:email- Backer's email address- Other fields from the Open Collective API
Example listener:
use Flarum\Extend; use FoF\OpenCollective\Event\BackerAdded; return [ (new Extend\Event) ->listen(BackerAdded::class, function (BackerAdded $event) { $user = $event->user; $email = $event->backerData->email ?? null; // Your custom logic here // e.g., send a welcome email, grant additional permissions, etc. }), ];
FoF\OpenCollective\Event\BackerRemoved
Dispatched when a user is removed from the backers group (backing ended).
Properties:
$user(Flarum\User\User) - The Flarum user who was removed
Example listener:
use Flarum\Extend; use FoF\OpenCollective\Event\BackerRemoved; return [ (new Extend\Event) ->listen(BackerRemoved::class, function (BackerRemoved $event) { $user = $event->user; // Your custom logic here // e.g., send a thank you message, revoke special access, etc. }), ];
Notes on Events
- Events are not dispatched when running with the
--dry-runflag - Events fire after the database changes have been made
- The
BackerAddedevent includes raw Open Collective data for additional context - These events only fire for automated changes, not manual group assignments
Troubleshooting
No backers are being synced
- Verify your token is correct and has proper permissions
- Check that the collective slug matches your Open Collective account exactly
- Ensure the cron job is running (
schedule:run) - Check logs in
storage/logs/fof-open-collective.log
Some backers aren't being matched
- Ensure backers have public email addresses on their Open Collective profiles
- Verify that corresponding Flarum users exist with the same email addresses
- Check that Flarum user emails are confirmed
Authentication errors
- If using a Personal Token, ensure it was created correctly
- If using a legacy API Key, consider migrating to a Personal Token
- Check that the token hasn't expired or been revoked
Updating
composer update fof/open-collective php flarum migrate php flarum cache:clear
Links
An extension by FriendsOfFlarum.