Understanding the internal structure and design of BuddyPress Moderation Pro for developers who want to extend or customize the plugin.
Directory Structure
The plugin follows WordPress coding standards with a clear separation of concerns:
- includes/ – Core functionality and shared classes
- admin/ – Admin panel, settings tabs, and meta boxes
- public/ – Frontend UI, content handlers, and AJAX endpoints
- templates/ – Overridable template files
- languages/ – Translation files
Core Classes
Main Orchestrator
Buddypress_Moderation_Pro (includes/class-buddypress-moderation-pro.php) is the main plugin class that:
- Defines plugin constants
- Loads all dependencies
- Sets locale for internationalization
- Initializes admin and public hooks
Hook Loader
Buddypress_Moderation_Pro_Loader provides centralized hook registration, queuing all actions and filters before executing them.
Content Type Handlers
Each content type has a dedicated handler class:
| Handler Class | Purpose |
|---|---|
| Activity_Moderation | Activity stream posts |
| Comments_Moderation | Activity comments |
| Members_Moderation | Member profiles and blocking |
| Groups_Moderation | BuddyPress groups |
| Messages_Moderation | Private messages |
| Topics_Moderation | bbPress forum topics |
| Replies_Moderation | bbPress forum replies |
| Avatar_Moderation | Profile and group avatars |
Data Flow
Report Submission Flow
- User clicks flag button → JavaScript opens modal
- User fills form with reason and details
- AJAX request sent with nonce verification
- PHP handler validates input and checks permissions
- Report post created (bmpro_spam post type)
- Meta data updated (reporter list, content meta)
- Action hooks fired (bpmp_*_flagged)
- Notifications sent (email and BuddyPress)
- Auto-moderation threshold checked
- Content hidden if threshold met
Content Visibility Flow
- Content query requested
- Filter hook fires (bp_ajax_querystring)
- Get excluded IDs via bmpro_exclude_moderated_content()
- Check user context (admin, reporter, content owner)
- Return content with flag indicator OR filter out from query
Database Schema
Custom Post Types
bmpro_spam – Report Log entries stored in wp_posts table
Key Meta Fields:
bmpro_spam_activity_id– Original content IDbmpro_spam_reported_by– Array of reporter user IDsbmpro_spam_status– awaiting_moderation or spambmpro_hide_mode– reporters or all_usersbmpro_member_actions– Actions taken on memberbmpro_lock_member_account– Account lock status
bmpro_avatar_spam – Avatar moderation entries
Key Meta Fields:
_bp_user_id– User ID for profile avatars_bp_group_id– Group ID for group avatars_bp_user_avatar_flag– 0=pending, 1=approved, 2=rejected_bp_is_group_avatar– Boolean for group avatars
Taxonomy
The bmpro_content_type taxonomy categorizes reports with terms: activity_update, activity_comment, member, group, message, topic, reply, group_avatar, user_avatar
Caching System
The plugin includes a performance caching system (class-bmpro-cache.php) providing:
- Batch preloading – Fetches moderation data in single queries when activity loops start
- Object caching – Uses wp_cache for persistent caching (works with Redis/Memcached)
- Runtime cache – Fast in-memory cache for current request
- Auto-invalidation – Cache cleared when data changes
Cache Keys
activity_mod_{id}– Activity moderation statusmember_flagged_meta_{id}– Member flagged statususer_block_{id}– User’s block listuser_blocked_by_{id}– Who has blocked this useruser_flagged_{id}– User’s flagged activities
Template System
Templates in the templates/ directory can be overridden in your theme:
bmpo-bp-moderations.php– Moderation queue templateblocking.php– Block user interfaceblocked.php– Blocked members list
Copy templates to your-theme/buddypress-moderation-pro/ to customize.
