Skip to Content
Frontlane Studio
All Snippets
Bash BuddyBoss July 15, 2025

BuddyBoss: Generate a Group Activity Report

Quickly get a snapshot of which groups are the most active. This script lists all groups and shows the total number of members and the number of new activity posts in the last 30 days.

BuddyBoss WordPress

Quickly get a snapshot of which groups are the most active. This script lists all groups and shows the total number of members and the number of new activity posts in the last 30 days.

#!/bin/bash

# Generates an activity report for all BuddyBoss groups.

echo "Generating Group Activity Report (Last 30 Days)..."
echo "----------------------------------------------------"
printf "%-10s %-40s %-15s %-15s\n" "Group ID" "Group Name" "Total Members" "New Activities"
echo "----------------------------------------------------"


# Get a list of all group IDs
GROUP_IDS=$(wp bp group list --format=ids)

# Date 30 days ago in the correct format for BuddyPress
DATE_30_DAYS_AGO=$(date -d "30 days ago" +"%Y-%m-%d %H:%M:%S")

for GROUP_ID in $GROUP_IDS; do
  # Get group details
  GROUP_NAME=$(wp bp group get --group_id=$GROUP_ID --field=name)
  MEMBER_COUNT=$(wp bp group get --group_id=$GROUP_ID --field=total_member_count)

  # Count activity items for the group in the last 30 days
  ACTIVITY_COUNT=$(wp bp activity list --filter="object=groups&primary_id=$GROUP_ID&since=$DATE_30_DAYS_AGO" --format=count)

  printf "%-10s %-40s %-15s %-15s\n" "$GROUP_ID" "$GROUP_NAME" "$MEMBER_COUNT" "$ACTIVITY_COUNT"
done

echo "----------------------------------------------------"
echo "Report complete."

How to Use:

  1. Save the script as group_activity_report.sh.

  2. Make it executable: chmod +x group_activity_report.sh.

  3. Simply run the script: ./group_activity_report.sh.