Hooks and Filters Reference
BuddyPress Moderation Pro overviewPremiumGet BuddyPress Moderation Pro →
Complete reference for all action hooks and filter hooks available in BuddyPress Moderation Pro.
Table of Contents
Section titled “Table of Contents”Action Hooks
Section titled “Action Hooks”Action hooks allow you to execute custom code at specific points in the plugin’s execution.
Reporting Actions
Section titled “Reporting Actions”bpmp_members_flagged
Section titled “bpmp_members_flagged”Fires when a member is reported/flagged.
Parameters:
int $member_id- ID of the reported memberint $reporter_id- ID of the user reportingint $post_id- ID of the report post
Location:
public/class-buddypress-members-moderation.phpincludes/class-bmpro-cli.php
Example:
add_action( 'bpmp_members_flagged', 'my_custom_member_flagged_handler', 10, 3 );
function my_custom_member_flagged_handler( $member_id, $reporter_id, $post_id ) { // Log the report error_log( sprintf( 'Member %d was reported by user %d (Report ID: %d)', $member_id, $reporter_id, $post_id ) );
// Send custom notification $member = get_userdata( $member_id ); $reporter = get_userdata( $reporter_id );
// Your custom logic here // - Send Slack notification // - Log to external service // - Trigger custom workflow}bpmp_activity_flagged
Section titled “bpmp_activity_flagged”Fires when an activity is reported.
Parameters:
int $activity_id- ID of the reported activityint $activity_user_id- ID of the activity authorint $reporter_id- ID of the user reportingstring $activity_subject- Subject of the reportint $post_id- ID of the report post
Location: public/class-buddypress-activity-moderation.php
Example:
add_action( 'bpmp_activity_flagged', 'my_activity_flagged_handler', 10, 5 );
function my_activity_flagged_handler( $activity_id, $activity_user_id, $reporter_id, $activity_subject, $post_id ) { // Get activity details $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id ) );
// Check if this is a repeat offender $previous_reports = get_posts( array( 'post_type' => 'bmpro_spam', 'meta_query' => array( array( 'key' => '_bpmp_activity_author_id', 'value' => $activity_user_id ) ) ) );
if ( count( $previous_reports ) > 5 ) { // Automatic suspension for repeat offenders update_user_meta( $activity_user_id, '_bmpro_suspended', 'yes' ); update_user_meta( $activity_user_id, '_bmpro_suspended_till', strtotime( '+7 days' ) ); }}bpmp_activity_comment_flagged
Section titled “bpmp_activity_comment_flagged”Fires when an activity comment is reported.
Parameters:
int $comment_id- ID of the reported commentint $reporter_id- ID of the user reportingint $comment_user_id- ID of the comment authorint $post_id- ID of the report post
Location: public/class-buddypress-comments-moderation.php
Example:
add_action( 'bpmp_activity_comment_flagged', 'log_comment_reports', 10, 4 );
function log_comment_reports( $comment_id, $reporter_id, $comment_user_id, $post_id ) { // Log to custom table for analytics global $wpdb; $wpdb->insert( $wpdb->prefix . 'custom_report_log', array( 'content_type' => 'activity_comment', 'content_id' => $comment_id, 'reporter_id' => $reporter_id, 'author_id' => $comment_user_id, 'report_date' => current_time( 'mysql' ) ) );}bpmp_groups_flagged
Section titled “bpmp_groups_flagged”Fires when a group is reported.
Parameters:
string $content_type- Always ‘groups’int $post_id- ID of the report postint $group_creator_id- ID of the group creatorint $reporter_id- ID of the user reportingstring $group_url- URL to the group
Location:
public/class-buddypress-groups-moderation.phpincludes/class-bmpro-cli.php
Example:
add_action( 'bpmp_groups_flagged', 'notify_group_admins_of_report', 10, 5 );
function notify_group_admins_of_report( $content_type, $post_id, $group_creator_id, $reporter_id, $group_url ) { // Get group ID from report meta $group_id = get_post_meta( $post_id, '_bmpro_item_id', true );
// Get all group admins $group_admins = groups_get_group_admins( $group_id );
foreach ( $group_admins as $admin ) { // Send email to each admin wp_mail( $admin->user_email, 'Group Reported', sprintf( 'Your group has been reported. View details: %s', admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ) ); }}bpmp_message_flagged
Section titled “bpmp_message_flagged”Fires when a private message is reported.
Parameters:
int $message_id- ID of the reported messageint $reporter_id- ID of the user reportingint $message_user_id- ID of the message senderint $post_id- ID of the report post
Location: public/class-buddypress-messages-moderation.php
Example:
add_action( 'bpmp_message_flagged', 'handle_message_report', 10, 4 );
function handle_message_report( $message_id, $reporter_id, $message_user_id, $post_id ) { // Get message content $message = new BP_Messages_Message( $message_id );
// Check for prohibited content $prohibited_words = array( 'spam', 'scam', 'phishing' );
foreach ( $prohibited_words as $word ) { if ( stripos( $message->message, $word ) !== false ) { // Auto-delete message messages_delete_thread( $message->thread_id );
// Notify sender bp_core_add_message( __( 'Your message violated our terms and was removed.', 'my-plugin' ), 'error' ); break; } }}bpmp_topic_flagged
Section titled “bpmp_topic_flagged”Fires when a bbPress topic is reported.
Parameters:
int $topic_id- ID of the reported topicint $topic_author- ID of the topic authorint $reporter_id- ID of the user reporting
Location: public/class-buddypress-topics-moderation.php
Example:
add_action( 'bpmp_topic_flagged', 'check_topic_spam', 10, 3 );
function check_topic_spam( $topic_id, $topic_author, $reporter_id ) { // Get topic content $topic_content = get_post_field( 'post_content', $topic_id );
// Check spam score $spam_score = my_custom_spam_checker( $topic_content );
if ( $spam_score > 0.8 ) { // High spam probability - hide topic bbp_spam_topic( $topic_id );
// Notify moderators $moderators = get_users( array( 'role' => 'bbp_moderator' ) ); foreach ( $moderators as $mod ) { bp_notifications_add_notification( array( 'user_id' => $mod->ID, 'item_id' => $topic_id, 'component_name' => 'moderation', 'component_action' => 'topic_auto_spammed' ) ); } }}bpmp_reply_flagged
Section titled “bpmp_reply_flagged”Fires when a bbPress reply is reported.
Parameters:
int $reply_id- ID of the reported replyint $reply_author- ID of the reply authorint $reporter_id- ID of the user reporting
Location: public/class-buddypress-replies-moderation.php
Example:
add_action( 'bpmp_reply_flagged', 'track_reply_reports', 10, 3 );
function track_reply_reports( $reply_id, $reply_author, $reporter_id ) { // Increment author's report count $report_count = (int) get_user_meta( $reply_author, '_total_reports_received', true ); update_user_meta( $reply_author, '_total_reports_received', $report_count + 1 );
// Check threshold if ( $report_count >= 10 ) { // Suspend user after 10 reports update_user_meta( $reply_author, '_bmpro_suspended', 'yes' ); update_user_meta( $reply_author, '_bmpro_suspended_till', strtotime( '+30 days' ) );
// Send notification wp_mail( get_user_by( 'id', $reply_author )->user_email, 'Account Suspended', 'Your account has been suspended due to multiple reports.' ); }}bpmp_avatar_flagged
Section titled “bpmp_avatar_flagged”Fires when an avatar (profile or group) is uploaded.
Parameters:
string $avatar_type- Either ‘profile_avatar’ or ‘group_avatar’int $post_id- ID of the avatar moderation postint $user_id- ID of the user who uploadedint $avatar_item_id- User ID for profile, Group ID for groupstring $url- URL to the profile/group
Location: public/class-buddypress-avatar-moderation.php
Example:
add_action( 'bpmp_avatar_flagged', 'scan_avatar_for_content', 10, 5 );
function scan_avatar_for_content( $avatar_type, $post_id, $user_id, $avatar_item_id, $url ) { // Get avatar file path if ( $avatar_type === 'profile_avatar' ) { $avatar_dir = bp_core_avatar_upload_path() . '/avatars/' . $avatar_item_id; } else { $avatar_dir = bp_core_avatar_upload_path() . '/group-avatars/' . $avatar_item_id; }
// Scan with image moderation API (e.g., AWS Rekognition, Google Vision) $moderation_result = my_image_moderation_api( $avatar_dir );
if ( $moderation_result['contains_explicit_content'] ) { // Auto-reject update_post_meta( $post_id, '_bp_user_avatar_flag', '2' ); // 2 = rejected
// Notify user bp_notifications_add_notification( array( 'user_id' => $user_id, 'item_id' => $post_id, 'component_name' => 'moderation', 'component_action' => 'avatar_rejected_auto' ) ); }}Moderation Actions
Section titled “Moderation Actions”bmpro_member_suspended
Section titled “bmpro_member_suspended”Fires when a member is suspended.
Parameters:
int $member_id- ID of the suspended memberint $duration- Suspension duration in daysstring $reason- Reason for suspension
Location: includes/class-bmpro-cli.php
Example:
add_action( 'bmpro_member_suspended', 'log_suspension_to_crm', 10, 3 );
function log_suspension_to_crm( $member_id, $duration, $reason ) { // Log to external CRM $user = get_userdata( $member_id );
wp_remote_post( 'https://your-crm.com/api/user-event', array( 'body' => json_encode( array( 'email' => $user->user_email, 'event' => 'account_suspended', 'duration_days' => $duration, 'reason' => $reason, 'timestamp' => current_time( 'timestamp' ) ) ) ) );
// Remove from mailing lists mailchimp_unsubscribe( $user->user_email );}bmpro_member_unsuspended
Section titled “bmpro_member_unsuspended”Fires when a member suspension is lifted.
Parameters:
int $member_id- ID of the unsuspended member
Location: includes/class-bmpro-cli.php
Example:
add_action( 'bmpro_member_unsuspended', 'restore_member_privileges', 10, 1 );
function restore_member_privileges( $member_id ) { // Restore custom capabilities $user = new WP_User( $member_id ); $user->add_cap( 'can_post_activities' ); $user->add_cap( 'can_send_messages' );
// Re-add to mailing lists $user_data = get_userdata( $member_id ); mailchimp_subscribe( $user_data->user_email );
// Send welcome back email wp_mail( $user_data->user_email, 'Welcome Back!', 'Your suspension has been lifted. Welcome back to the community!' );}bmpro_user_blocked
Section titled “bmpro_user_blocked”Fires when a user blocks another user.
Parameters:
int $member_id- ID of the blocked userint $blocker_id- ID of the user doing the blocking
Location:
public/class-buddypress-members-moderation.phpincludes/class-bmpro-cli.php
Example:
add_action( 'bmpro_user_blocked', 'track_user_blocks', 10, 2 );
function track_user_blocks( $member_id, $blocker_id ) { // Track block count $block_count = (int) get_user_meta( $member_id, '_times_blocked_by_others', true ); update_user_meta( $member_id, '_times_blocked_by_others', $block_count + 1 );
// If blocked by many users, flag for review if ( $block_count >= 10 ) { // Create automatic report $post_id = wp_insert_post( array( 'post_type' => 'bmpro_spam', 'post_title' => 'Auto-generated: User blocked by 10+ members', 'post_status' => 'publish' ) );
update_post_meta( $post_id, '_bmpro_item_id', $member_id ); update_post_meta( $post_id, '_bmpro_spam_status', 'awaiting_moderation' ); }}bmpro_user_unblocked
Section titled “bmpro_user_unblocked”Fires when a user unblocks another user.
Parameters:
int $member_id- ID of the unblocked userint $blocker_id- ID of the user doing the unblocking
Location:
public/class-buddypress-members-moderation.phpincludes/class-bmpro-cli.php
Example:
add_action( 'bmpro_user_unblocked', 'log_unblock_event', 10, 2 );
function log_unblock_event( $member_id, $blocker_id ) { // Decrease block count $block_count = (int) get_user_meta( $member_id, '_times_blocked_by_others', true ); if ( $block_count > 0 ) { update_user_meta( $member_id, '_times_blocked_by_others', $block_count - 1 ); }
// Log event do_action( 'my_custom_analytics', 'user_unblocked', array( 'unblocked_user' => $member_id, 'unblocked_by' => $blocker_id ) );}Settings Actions
Section titled “Settings Actions”bmpro_add_general_settings_options
Section titled “bmpro_add_general_settings_options”Fires in general settings tab to allow adding custom settings.
Parameters:
array $bmpro_gen_stngs- Current general settings
Location: admin/inc/bmpro-general-setting-tab.php
Example:
add_action( 'bmpro_add_general_settings_options', 'add_custom_general_settings' );
function add_custom_general_settings( $bmpro_gen_stngs ) { $custom_setting = isset( $bmpro_gen_stngs['my_custom_option'] ) ? $bmpro_gen_stngs['my_custom_option'] : 'no'; ?> <tr> <th scope="row"> <label for="my_custom_option"><?php _e( 'My Custom Option', 'my-plugin' ); ?></label> </th> <td> <input type="checkbox" name="bmpro_gen_stngs[my_custom_option]" id="my_custom_option" value="yes" <?php checked( $custom_setting, 'yes' ); ?> /> <label for="my_custom_option"> <?php _e( 'Enable my custom feature', 'my-plugin' ); ?> </label> </td> </tr> <?php}bmpro_restrictions_settings_options
Section titled “bmpro_restrictions_settings_options”Fires in restrictions settings tab to allow adding custom restriction settings.
Parameters:
array $bmpro_restriction_settings- Current restriction settings
Location: admin/inc/bmpro-restrictions-setting-tab.php
Example:
add_action( 'bmpro_restrictions_settings_options', 'add_custom_restrictions' );
function add_custom_restrictions( $bmpro_restriction_settings ) { ?> <h3><?php _e( 'Custom Restrictions', 'my-plugin' ); ?></h3> <table class="form-table"> <tr> <th scope="row"> <label><?php _e( 'IP Blocking', 'my-plugin' ); ?></label> </th> <td> <textarea name="bmpro_restrictions[blocked_ips]" rows="5" class="large-text"><?php echo isset( $bmpro_restriction_settings['blocked_ips'] ) ? esc_textarea( $bmpro_restriction_settings['blocked_ips'] ) : ''; ?></textarea> <p class="description"><?php _e( 'Enter one IP address per line', 'my-plugin' ); ?></p> </td> </tr> </table> <?php}bmpro_create_meta_box_for_content_type
Section titled “bmpro_create_meta_box_for_content_type”Fires when creating custom meta boxes for different content types.
Parameters:
string $term_slug- Content type term slug (member, activity, group, etc.)
Location: admin/class-buddypress-moderation-pro-admin.php
Example:
add_action( 'bmpro_create_meta_box_for_content_type', 'add_custom_content_type_metabox', 10, 1 );
function add_custom_content_type_metabox( $term_slug ) { if ( $term_slug === 'activity' ) { add_meta_box( 'bmpro_custom_activity_actions', __( 'Custom Activity Actions', 'my-plugin' ), 'render_custom_activity_metabox', 'bmpro_spam', 'side', 'high' ); }}
function render_custom_activity_metabox( $post ) { $activity_id = get_post_meta( $post->ID, '_bmpro_item_id', true ); ?> <p> <a href="<?php echo admin_url( 'admin.php?page=my-custom-activity-editor&activity_id=' . $activity_id ); ?>" class="button"> <?php _e( 'Edit Activity Content', 'my-plugin' ); ?> </a> </p> <?php}Cleanup Actions
Section titled “Cleanup Actions”bmpro_spam_cleanup_filter_function
Section titled “bmpro_spam_cleanup_filter_function”Fires when cleaning up/deleting reported content.
Parameters:
int $post_id- ID of the report post being cleanedstring $content_type- Type of content (member, activity, etc.)int $spam_id- ID of the spammed content item
Location:
admin/class-buddypress-moderation-pro-cleanup.phppublic/class-buddypress-moderation-pro-public.php
Example:
add_action( 'bmpro_spam_cleanup_filter_function', 'custom_cleanup_handler', 10, 3 );
function custom_cleanup_handler( $post_id, $content_type, $spam_id ) { // Log cleanup to external service error_log( sprintf( 'Cleaning up %s (ID: %d) from report %d', $content_type, $spam_id, $post_id ) );
// Remove from custom caches if ( $content_type === 'activity' ) { wp_cache_delete( 'activity_' . $spam_id, 'bp_activity' );
// Also clear related caches $activity = bp_activity_get_specific( array( 'activity_ids' => $spam_id ) ); if ( ! empty( $activity['activities'][0] ) ) { $user_id = $activity['activities'][0]->user_id; wp_cache_delete( 'user_activity_count_' . $user_id, 'bp_activity' ); } }
// Notify external systems do_action( 'my_plugin_content_removed', $content_type, $spam_id );}Filter Hooks
Section titled “Filter Hooks”Filter hooks allow you to modify data before it’s used or displayed.
Content Filters
Section titled “Content Filters”bmpro_content_to_flag
Section titled “bmpro_content_to_flag”Filters the array of content types that can be flagged.
Parameters:
array $contents- Array of content types with their labels
Location: includes/buddypress-moderation-pro-functions.php
Default Value:
array( 'restrictions' => __( 'Restrictions', 'buddypress-moderation-pro' ), 'profile_avatar' => __( 'Avatar Moderation', 'buddypress-moderation-pro' ), 'reported-keyword' => __( 'Categorize By Report', 'buddypress-moderation-pro' ),)Example:
add_filter( 'bmpro_content_to_flag', 'add_custom_content_types' );
function add_custom_content_types( $contents ) { // Add custom content type $contents['custom_post_type'] = __( 'My Custom Posts', 'my-plugin' ); $contents['woocommerce_products'] = __( 'Products', 'my-plugin' );
return $contents;}bmpro_spam_statuses_types
Section titled “bmpro_spam_statuses_types”Filters the available spam status types.
Parameters:
array $statuses- Array of status options
Location: includes/buddypress-moderation-pro-functions.php
Default Value:
array( '' => __( 'All', 'buddypress-moderation-pro' ), 'pending' => __( 'Pending', 'buddypress-moderation-pro' ), 'spam' => __( 'Spam', 'buddypress-moderation-pro' ), 'approved' => __( 'Approved', 'buddypress-moderation-pro' ))Example:
add_filter( 'bmpro_spam_statuses_types', 'add_custom_status_types' );
function add_custom_status_types( $statuses ) { // Add custom statuses $statuses['under_review'] = __( 'Under Review', 'my-plugin' ); $statuses['escalated'] = __( 'Escalated', 'my-plugin' ); $statuses['false_positive'] = __( 'False Positive', 'my-plugin' );
return $statuses;}bpmp_exclude_moderated_content
Section titled “bpmp_exclude_moderated_content”Filters content IDs to exclude from queries (for hiding moderated content).
Parameters:
array $exclude_ids- Array of IDs to excludestring $object- Object type (activity, member, group, etc.)int $object_id- Specific object ID being checked
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bpmp_exclude_moderated_content', 'custom_content_exclusion', 10, 3 );
function custom_content_exclusion( $exclude_ids, $object, $object_id ) { // Additionally hide content from users in custom blacklist if ( $object === 'activity' ) { $blacklisted_users = get_option( 'my_custom_blacklist', array() );
if ( ! empty( $blacklisted_users ) ) { global $wpdb; $bp = buddypress();
$blacklisted_activities = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id IN (" . implode(',', array_map('absint', $blacklisted_users)) . ")" ) );
$exclude_ids = array_merge( $exclude_ids, $blacklisted_activities ); } }
return array_unique( $exclude_ids );}buddypress_moderation_theme_suuport
Section titled “buddypress_moderation_theme_suuport”Filters the array of supported themes.
Parameters:
array- Array of supported theme slugs
Location: includes/buddypress-moderation-pro-functions.php
Default Value:
array( 'reign-theme', 'buddyx', 'buddyx-pro' )Example:
add_filter( 'buddypress_moderation_theme_suuport', 'add_my_theme_support' );
function add_my_theme_support( $themes ) { $themes[] = 'my-custom-theme'; $themes[] = 'another-theme';
return $themes;}Settings Filters
Section titled “Settings Filters”bmpro_auto_mod_limit_filter
Section titled “bmpro_auto_mod_limit_filter”Filters the auto-moderation threshold limit.
Parameters:
int $auto_mod_limit- Number of reports before auto-moderationarray $bmpro_gen_stngs- General settings array
Location: includes/buddypress-moderation-pro-functions.php
Default Value: 5 (if not set in settings)
Example:
add_filter( 'bmpro_auto_mod_limit_filter', 'dynamic_auto_mod_threshold', 10, 2 );
function dynamic_auto_mod_threshold( $auto_mod_limit, $bmpro_gen_stngs ) { // Lower threshold for new users (higher sensitivity) if ( is_user_logged_in() ) { $user = wp_get_current_user(); $registration_days = ( time() - strtotime( $user->user_registered ) ) / DAY_IN_SECONDS;
if ( $registration_days < 30 ) { // New users: 3 reports return 3; } elseif ( $registration_days < 90 ) { // Intermediate users: 5 reports return 5; } }
// Established users: 7 reports return 7;}bmpro_auto_moderation_enable
Section titled “bmpro_auto_moderation_enable”Filters whether auto-moderation is enabled for a component.
Parameters:
bool $auto_mod_on- Whether auto-moderation is enabledstring $component- Component name (activity, member, group, etc.)
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_auto_moderation_enable', 'conditional_auto_moderation', 10, 2 );
function conditional_auto_moderation( $auto_mod_on, $component ) { // Disable auto-moderation during specific hours (e.g., office hours for manual review) $current_hour = (int) current_time( 'H' );
if ( $current_hour >= 9 && $current_hour <= 17 ) { // Office hours: disable auto-mod for manual review return false; }
// Enable auto-mod for activities but not groups if ( $component === 'group' ) { return false; }
return $auto_mod_on;}bmpro_get_flag_unflag_text
Section titled “bmpro_get_flag_unflag_text”Filters the flag/unflag button text.
Parameters:
string $bmpro_text- Button text
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_get_flag_unflag_text', 'translate_flag_button_text' );
function translate_flag_button_text( $bmpro_text ) { // Change text based on user language or preference $user_lang = get_user_locale();
if ( $bmpro_text === 'Flag' ) { switch ( $user_lang ) { case 'es_ES': return 'Reportar'; case 'fr_FR': return 'Signaler'; case 'de_DE': return 'Melden'; } }
return $bmpro_text;}bmpro_get_is_enabled_flagging
Section titled “bmpro_get_is_enabled_flagging”Filters whether flagging is enabled for specific content.
Parameters:
bool $selected- Whether flagging is enabled
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_get_is_enabled_flagging', 'conditional_flagging_enable', 10, 1 );
function conditional_flagging_enable( $selected ) { // Disable flagging for administrators' content if ( bp_displayed_user_id() ) { $user = get_userdata( bp_displayed_user_id() ); if ( $user && in_array( 'administrator', $user->roles ) ) { return false; } }
// Disable flagging on specific pages if ( is_page( 'about' ) || is_page( 'contact' ) ) { return false; }
return $selected;}Moderation Filters
Section titled “Moderation Filters”bmpro_member_related_actions_filter
Section titled “bmpro_member_related_actions_filter”Filters the available actions for reported members.
Parameters:
array $actions- Array of action options
Location: includes/buddypress-moderation-pro-functions.php
Default Value:
array( 'no_action' => __( 'No action', 'buddypress-moderation-pro' ), 'spammer' => __( 'Mark user as spammer', 'buddypress-moderation-pro' ), // ... more actions)Example:
add_filter( 'bmpro_member_related_actions_filter', 'add_custom_member_actions' );
function add_custom_member_actions( $actions ) { // Add custom actions $actions['warning_email'] = __( 'Send Warning Email', 'my-plugin' ); $actions['restrict_posting'] = __( 'Restrict Posting Ability', 'my-plugin' ); $actions['require_verification'] = __( 'Require Re-verification', 'my-plugin' );
// Reorder actions $ordered_actions = array(); $ordered_actions['no_action'] = $actions['no_action']; $ordered_actions['warning_email'] = $actions['warning_email']; unset( $actions['no_action'], $actions['warning_email'] ); $ordered_actions = array_merge( $ordered_actions, $actions );
return $ordered_actions;}bmpro_group_related_actions_filter
Section titled “bmpro_group_related_actions_filter”Filters the available actions for reported groups.
Parameters:
array $actions- Array of action options
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_group_related_actions_filter', 'add_custom_group_actions' );
function add_custom_group_actions( $actions ) { $actions['make_private'] = __( 'Convert to Private Group', 'my-plugin' ); $actions['remove_creator'] = __( 'Remove Group Creator', 'my-plugin' ); $actions['lock_membership'] = __( 'Lock New Memberships', 'my-plugin' );
return $actions;}bmpro_members_moderation_restrictions_filter
Section titled “bmpro_members_moderation_restrictions_filter”Filters member restriction options.
Parameters:
array $member_restrictions- Array of restriction options
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_members_moderation_restrictions_filter', 'add_member_restrictions' );
function add_member_restrictions( $member_restrictions ) { $member_restrictions['no_private_messages'] = __( 'Block Private Messages', 'my-plugin' ); $member_restrictions['no_group_creation'] = __( 'Disable Group Creation', 'my-plugin' ); $member_restrictions['read_only'] = __( 'Read-Only Access', 'my-plugin' );
return $member_restrictions;}bmpro_groups_moderation_restrictions_filter
Section titled “bmpro_groups_moderation_restrictions_filter”Filters group restriction options.
Parameters:
array $group_restrictions- Array of restriction options
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_groups_moderation_restrictions_filter', 'add_group_restrictions' );
function add_group_restrictions( $group_restrictions ) { $group_restrictions['no_new_members'] = __( 'Block New Members', 'my-plugin' ); $group_restrictions['admin_approval'] = __( 'Require Admin Approval for Posts', 'my-plugin' ); $group_restrictions['read_only'] = __( 'Read-Only Group', 'my-plugin' );
return $group_restrictions;}bmpro_account_lock_message_filter
Section titled “bmpro_account_lock_message_filter”Filters the message shown to locked users.
Parameters:
string $lock_message- Lock message
Location: includes/buddypress-moderation-pro-functions.php
Default: “Your account has been locked due to policy violations.”
Example:
add_filter( 'bmpro_account_lock_message_filter', 'custom_lock_message' );
function custom_lock_message( $lock_message ) { // Personalized message with appeal info return sprintf( __( 'Your account has been temporarily locked. If you believe this is an error, please contact support at %s with your username.', 'my-plugin' ), '<a href="mailto:support@example.com">support@example.com</a>' );}bmpro_remove_flagged_member_at_directory_page
Section titled “bmpro_remove_flagged_member_at_directory_page”Filters whether to remove flagged members from directory listings.
Parameters:
bool $remove- Whether to remove flagged members
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_remove_flagged_member_at_directory_page', 'conditional_member_removal' );
function conditional_member_removal( $remove ) { // Only remove for non-admins if ( current_user_can( 'manage_options' ) ) { return false; // Admins see all members }
// Remove flagged members for regular users return true;}bmpro_get_moderation_mode_filter
Section titled “bmpro_get_moderation_mode_filter”Filters the moderation mode (who can see hidden content).
Parameters:
string $moderation_mode- Moderation mode (‘all’ or ‘reporter’)
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_get_moderation_mode_filter', 'custom_moderation_visibility' );
function custom_moderation_visibility( $moderation_mode ) { // Moderators can see hidden content if ( current_user_can( 'moderate_community' ) ) { return 'moderator'; }
return $moderation_mode;}Notification Filters
Section titled “Notification Filters”_bprwg_notification_text
Section titled “_bprwg_notification_text”Filters notification text for various moderation events.
Parameters:
string- Notification text
Location: Multiple files (notifications, avatars, topics, replies)
Example:
add_filter( '_bprwg_notification_text', 'customize_notification_text', 10, 1 );
function customize_notification_text( $text ) { // Add custom branding $text .= sprintf( ' <a href="/bp-family/buddypress-moderation/developer-guide/%s/">%s</a>', site_url( '/community-guidelines/' ), __( 'Review Community Guidelines', 'my-plugin' ) );
// Make notifications more friendly $text = str_replace( 'has reported', 'flagged for review', $text );
return $text;}bmpro_filter_enabled_admin_flag_email
Section titled “bmpro_filter_enabled_admin_flag_email”Filters whether to send email notifications to admins.
Parameters:
bool $send- Whether to send emailarray $bmpro_stngs- Plugin settings
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_filter_enabled_admin_flag_email', 'conditional_admin_emails', 10, 2 );
function conditional_admin_emails( $send, $bmpro_stngs ) { // Don't send emails during night hours $current_hour = (int) current_time( 'H' ); if ( $current_hour >= 22 || $current_hour <= 6 ) { return false; }
// Don't send if daily limit reached $daily_emails = (int) get_transient( 'bmpro_daily_admin_emails' ); if ( $daily_emails >= 50 ) { return false; }
set_transient( 'bmpro_daily_admin_emails', $daily_emails + 1, DAY_IN_SECONDS );
return $send;}bmpro_filter_enabled_bp_notification
Section titled “bmpro_filter_enabled_bp_notification”Filters whether to send BuddyPress notifications.
Parameters:
bool $send- Whether to send notificationarray $bmpro_stngs- Plugin settings
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bmpro_filter_enabled_bp_notification', 'user_notification_preferences', 10, 2 );
function user_notification_preferences( $send, $bmpro_stngs ) { $user_id = bp_displayed_user_id();
if ( $user_id ) { // Check user's notification preferences $user_wants_notifications = get_user_meta( $user_id, 'bmpro_receive_notifications', true );
if ( $user_wants_notifications === 'no' ) { return false; } }
return $send;}Permission Filters
Section titled “Permission Filters”bmpro_allow_activity_update_user_roles
Section titled “bmpro_allow_activity_update_user_roles”Filters which user roles can update/moderate activities.
Parameters:
array- Array of allowed role slugs
Location: Multiple files (activity, comments, messages)
Default Value:
array( 'administrator', 'bp_moderator_pro' )Example:
add_filter( 'bmpro_allow_activity_update_user_roles', 'add_moderator_roles' );
function add_moderator_roles( $roles ) { // Add custom moderator roles $roles[] = 'community_manager'; $roles[] = 'senior_moderator'; $roles[] = 'editor'; // WordPress editor role
return $roles;}bpmp_moderator_users
Section titled “bpmp_moderator_users”Filters the list of moderator user IDs.
Parameters:
array|bool $user_ids- Array of user IDs or false
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bpmp_moderator_users', 'add_dynamic_moderators' );
function add_dynamic_moderators( $user_ids ) { // Add users with high reputation as temporary moderators $high_reputation_users = get_users( array( 'meta_key' => 'community_reputation', 'meta_value' => 1000, 'meta_compare' => '>=', 'fields' => 'ID' ) );
if ( is_array( $user_ids ) ) { $user_ids = array_merge( $user_ids, $high_reputation_users ); } else { $user_ids = $high_reputation_users; }
return array_unique( $user_ids );}bpmp_get_users
Section titled “bpmp_get_users”Filters the array of available users for selection.
Parameters:
array $users- Array of user objects
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bpmp_get_users', 'filter_available_users' );
function filter_available_users( $users ) { // Only show verified users $verified_users = array();
foreach ( $users as $user ) { if ( get_user_meta( $user->ID, 'account_verified', true ) === 'yes' ) { $verified_users[] = $user; } }
return $verified_users;}get_blocked_users
Section titled “get_blocked_users”Filters the list of blocked users for a specific user.
Parameters:
array $bmpro_block- Array of blocked user IDsint $user_id- User ID doing the blocking
Location: public/class-buddypress-members-moderation.php
Example:
add_filter( 'get_blocked_users', 'add_system_blocked_users', 10, 2 );
function add_system_blocked_users( $bmpro_block, $user_id ) { // Add system-wide blocked users (spammers, banned, etc.) $system_blocked = get_users( array( 'meta_key' => '_bmpro_globally_blocked', 'meta_value' => 'yes', 'fields' => 'ID' ) );
$bmpro_block = array_merge( $bmpro_block, $system_blocked );
return array_unique( $bmpro_block );}Utility Filters
Section titled “Utility Filters”bpmp_get_edit_post_link
Section titled “bpmp_get_edit_post_link”Filters the edit link for moderated content.
Parameters:
string $link- Edit link URLint $post_id- Post IDstring $context- Context (‘display’ or other)object $user- User object
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bpmp_get_edit_post_link', 'custom_edit_link', 10, 4 );
function custom_edit_link( $link, $post_id, $context, $user ) { // Redirect to custom moderation interface if ( $context === 'display' ) { $link = admin_url( 'admin.php?page=custom-moderation&report_id=' . $post_id ); }
return $link;}bpmp_members_get_user_url
Section titled “bpmp_members_get_user_url”Filters the member profile URL.
Parameters:
string $url- Profile URLint $author_id- User ID
Location: includes/buddypress-moderation-pro-functions.php
Example:
add_filter( 'bpmp_members_get_user_url', 'custom_profile_url', 10, 2 );
function custom_profile_url( $url, $author_id ) { // Use custom profile page for specific users $user = get_userdata( $author_id );
if ( $user && in_array( 'vip_member', $user->roles ) ) { $url = home_url( '/vip-profile/' . $user->user_nicename ); }
return $url;}bmpro_default_flagged_content_meta_box
Section titled “bmpro_default_flagged_content_meta_box”Filters whether to show the default meta box for a content type.
Parameters:
bool $show- Whether to show default meta boxstring $term_slug- Content type term slug
Location: admin/class-buddypress-moderation-pro-admin.php
Example:
add_filter( 'bmpro_default_flagged_content_meta_box', 'hide_default_metabox_for_custom_types', 10, 2 );
function hide_default_metabox_for_custom_types( $show, $term_slug ) { // Hide default meta box for custom content types $custom_types = array( 'woocommerce_product', 'custom_post_type' );
if ( in_array( $term_slug, $custom_types ) ) { return false; // Hide default, we'll add our own }
return $show;}bmpro_default_flagged_content_cleanup
Section titled “bmpro_default_flagged_content_cleanup”Filters whether to use default cleanup for a content type.
Parameters:
bool $use_default- Whether to use default cleanupstring $content_type- Content type
Location: admin/class-buddypress-moderation-pro-cleanup.php
Example:
add_filter( 'bmpro_default_flagged_content_cleanup', 'custom_cleanup_for_types', 10, 2 );
function custom_cleanup_for_types( $use_default, $content_type ) { // Use custom cleanup for specific types if ( $content_type === 'woocommerce_product' ) { return false; // Don't use default, we'll handle it }
return $use_default;}Usage Examples
Section titled “Usage Examples”Example 1: Custom Content Type Integration
Section titled “Example 1: Custom Content Type Integration”/** * Add WooCommerce products as reportable content */
// Add to content typesadd_filter( 'bmpro_content_to_flag', 'add_wc_product_reporting' );function add_wc_product_reporting( $contents ) { $contents['wc_product'] = __( 'Products', 'my-plugin' ); return $contents;}
// Handle product reportsadd_action( 'bmpro_product_flagged', 'handle_product_report', 10, 3 );function handle_product_report( $product_id, $reporter_id, $post_id ) { // Update product status update_post_meta( $product_id, '_reported_count', (int) get_post_meta( $product_id, '_reported_count', true ) + 1 );
// Notify shop manager $shop_managers = get_users( array( 'role' => 'shop_manager' ) ); foreach ( $shop_managers as $manager ) { wp_mail( $manager->user_email, 'Product Reported', sprintf( 'Product #%d has been reported. Review: %s', $product_id, admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ) ); }}
// Add custom actions for productsadd_filter( 'bmpro_product_related_actions_filter', 'add_product_actions' );function add_product_actions( $actions ) { $actions['unpublish'] = __( 'Unpublish Product', 'my-plugin' ); $actions['pending_review'] = __( 'Set to Pending Review', 'my-plugin' ); return $actions;}Example 2: Advanced Auto-Moderation
Section titled “Example 2: Advanced Auto-Moderation”/** * Implement reputation-based auto-moderation */
add_filter( 'bmpro_auto_mod_limit_filter', 'reputation_based_threshold', 10, 2 );function reputation_based_threshold( $auto_mod_limit, $bmpro_gen_stngs ) { if ( ! is_user_logged_in() ) { return $auto_mod_limit; }
$user_id = get_current_user_id(); $reputation = (int) get_user_meta( $user_id, 'community_reputation', true );
// Higher reputation = higher threshold (less likely to be auto-moderated) if ( $reputation > 1000 ) { return 10; // Trusted users } elseif ( $reputation > 500 ) { return 7; // Regular users } elseif ( $reputation > 100 ) { return 5; // New active users } else { return 3; // New/low reputation users }}
// Adjust reputation based on moderation outcomesadd_action( 'bmpro_spam_cleanup_filter_function', 'adjust_reputation_on_spam', 10, 3 );function adjust_reputation_on_spam( $post_id, $content_type, $spam_id ) { $author_id = get_post_meta( $post_id, '_bpmp_author_id', true );
if ( $author_id ) { $reputation = (int) get_user_meta( $author_id, 'community_reputation', true ); update_user_meta( $author_id, 'community_reputation', max( 0, $reputation - 50 ) ); }}Example 3: Custom Notification System
Section titled “Example 3: Custom Notification System”/** * Send notifications to Slack when content is reported */
add_action( 'bpmp_activity_flagged', 'send_slack_notification', 10, 5 );function send_slack_notification( $activity_id, $activity_user_id, $reporter_id, $activity_subject, $post_id ) { $webhook_url = get_option( 'my_plugin_slack_webhook' );
if ( ! $webhook_url ) { return; }
$reporter = get_userdata( $reporter_id ); $author = get_userdata( $activity_user_id ); $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id ) );
$message = array( 'text' => sprintf( ':warning: *Activity Reported*\n' . '*Reporter:* %s\n' . '*Author:* %s\n' . '*Subject:* %s\n' . '*Content:* %s\n' . '*Review:* <%s|Click here>', $reporter->display_name, $author->display_name, $activity_subject, wp_trim_words( strip_tags( $activity['activities'][0]->content ), 20 ), admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ) );
wp_remote_post( $webhook_url, array( 'body' => json_encode( $message ), 'headers' => array( 'Content-Type' => 'application/json' ) ) );}Example 4: Integration with MemberPress
Section titled “Example 4: Integration with MemberPress”/** * Suspend member subscriptions when account is suspended */
add_action( 'bmpro_member_suspended', 'suspend_memberpress_subscription', 10, 3 );function suspend_memberpress_subscription( $member_id, $duration, $reason ) { if ( ! class_exists( 'MeprUser' ) ) { return; }
$user = new MeprUser( $member_id ); $subscriptions = $user->active_product_subscriptions();
foreach ( $subscriptions as $subscription ) { $subscription->status = 'suspended'; $subscription->store();
// Add note $note = sprintf( 'Subscription suspended due to community moderation: %s (Duration: %d days)', $reason, $duration ); $subscription->add_note( $note ); }}
// Restore subscriptions when unsuspendedadd_action( 'bmpro_member_unsuspended', 'restore_memberpress_subscription', 10, 1 );function restore_memberpress_subscription( $member_id ) { if ( ! class_exists( 'MeprUser' ) ) { return; }
$user = new MeprUser( $member_id ); $subscriptions = $user->subscriptions();
foreach ( $subscriptions as $subscription ) { if ( $subscription->status === 'suspended' ) { $subscription->status = 'active'; $subscription->store(); $subscription->add_note( 'Subscription restored - moderation lifted' ); } }}Best Practices
Section titled “Best Practices”Hook Priority
Section titled “Hook Priority”Use appropriate priorities when adding hooks:
// Early execution (before plugin defaults)add_filter( 'bmpro_content_to_flag', 'my_function', 5 );
// Default execution (same as plugin)add_action( 'bpmp_activity_flagged', 'my_function', 10 );
// Late execution (after plugin processing)add_filter( 'bmpro_auto_mod_limit_filter', 'my_function', 20 );Check for Existence
Section titled “Check for Existence”Always check if functions/classes exist:
add_action( 'bpmp_activity_flagged', 'my_handler', 10, 5 );function my_handler( $activity_id, $activity_user_id, $reporter_id, $activity_subject, $post_id ) { // Check if BuddyPress is active if ( ! function_exists( 'bp_activity_get_specific' ) ) { return; }
// Your code here}Use Proper Sanitization
Section titled “Use Proper Sanitization”Always sanitize and validate data:
add_filter( 'bmpro_content_to_flag', 'add_custom_type' );function add_custom_type( $contents ) { $contents['my_type'] = sanitize_text_field( __( 'My Type', 'my-plugin' ) ); return $contents;}Return Values
Section titled “Return Values”Always return a value in filters:
// GOODadd_filter( 'bmpro_auto_mod_limit_filter', 'my_filter' );function my_filter( $limit ) { return (int) $limit;}
// BADadd_filter( 'bmpro_auto_mod_limit_filter', 'my_bad_filter' );function my_bad_filter( $limit ) { $limit = $limit + 1; // No return!}Documentation
Section titled “Documentation”Document your custom hooks:
/** * Handle member report * * @param int $member_id ID of reported member * @param int $reporter_id ID of reporter * @param int $post_id Report post ID */add_action( 'bpmp_members_flagged', 'my_member_report_handler', 10, 3 );function my_member_report_handler( $member_id, $reporter_id, $post_id ) { // Implementation}Performance
Section titled “Performance”Avoid heavy operations in hooks that fire frequently:
// GOOD - Cache resultsadd_filter( 'bpmp_exclude_moderated_content', 'exclude_content' );function exclude_content( $exclude_ids ) { $cached = wp_cache_get( 'my_excluded_ids', 'my_plugin' ); if ( $cached !== false ) { return array_merge( $exclude_ids, $cached ); }
// Expensive query $ids = get_expensive_data(); wp_cache_set( 'my_excluded_ids', $ids, 'my_plugin', HOUR_IN_SECONDS );
return array_merge( $exclude_ids, $ids );}Troubleshooting
Section titled “Troubleshooting”Hook Not Firing
Section titled “Hook Not Firing”If your hook isn’t firing:
- Check the hook name is correct
- Verify priority (lower numbers execute first)
- Ensure plugin is loaded after BuddyPress Moderation Pro
- Check for PHP errors in debug.log
Filter Not Working
Section titled “Filter Not Working”If your filter isn’t working:
- Ensure you’re returning a value
- Check parameter count matches
- Verify filter priority
- Use
var_dump()to debug values
Performance Issues
Section titled “Performance Issues”If hooks cause performance issues:
- Use caching
- Check database queries
- Avoid N+1 queries
- Use transients for expensive operations
Last Updated: 2025-10-09 Plugin Version: 4.x+ WordPress: 5.0+ BuddyPress: 7.0+
For more information:

