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

BuddyBoss: Bulk Message All Members of a Specific Group

This script sends a direct message to every member of a specified group. This is incredibly useful for important announcements, updates, or engaging with specific segments of your community.

BuddyBoss WordPress

This script sends a direct message to every member of a specified group. This is incredibly useful for important announcements, updates, or engaging with specific segments of your community.

#!/bin/bash

# Usage: ./bulk_message_group.sh <group_id> "Your message here"

# Check if both group ID and message are provided
if [ -z "$1" ] || [ -z "$2" ]; then
  echo "Usage: $0 <group_id> \"<message>\""
  exit 1
fi

GROUP_ID=$1
MESSAGE=$2
SENDER_ID=1 # ID of the user sending the message (e.g., admin)

# Get a list of all member IDs in the specified group
MEMBER_IDS=$(wp bp group member list --group_id=$GROUP_ID --format=ids)

# Check if the group has any members
if [ -z "$MEMBER_IDS" ]; then
  echo "No members found in group $GROUP_ID."
  exit 0
fi

# Loop through each member and send the message
for MEMBER_ID in $MEMBER_IDS; do
  # Skip sending the message to the sender
  if [ "$MEMBER_ID" -eq "$SENDER_ID" ]; then
    continue
  fi

  wp bp message create --from=$SENDER_ID --to=$MEMBER_ID --subject="An Important Group Update" --message="$MESSAGE"
  echo "Message sent to member $MEMBER_ID"
done

echo "Bulk messaging complete."

How to Use:

  1. Save the script as bulk_message_group.sh.

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

  3. Run it with the group ID and your message: ./bulk_message_group.sh 123 “Hey everyone, our weekly webinar is starting in one hour!”