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

BuddyBoss: Sync Member Profile Field from WordPress User Meta

This script is perfect for situations where you have user data in the standard wp_usermeta table (perhaps from a registration form or another plugin) and you want to display it in a BuddyBoss profile field.

BuddyBoss WordPress

This script is perfect for situations where you have user data in the standard wp_usermeta table (perhaps from a registration form or another plugin) and you want to display it in a BuddyBoss profile field.

#!/bin/bash

# Usage: ./sync_profile_field.sh <meta_key> <profile_field_id>

# Check for required arguments
if [ -z "$1" ] || [ -z "$2" ]; then
  echo "Usage: $0 <user_meta_key> <buddyboss_profile_field_id>"
  exit 1
fi

META_KEY=$1
FIELD_ID=$2

# Get all user IDs
USER_IDS=$(wp user list --field=ID)

for USER_ID in $USER_IDS; do
  # Get the value from the user meta table
  META_VALUE=$(wp user meta get $USER_ID $META_KEY --format=json | jq -r '.[0]')

  if [ -n "$META_VALUE" ] && [ "$META_VALUE" != "null" ]; then
    # Update the BuddyBoss profile field
    wp bp xprofile data set --user_id=$USER_ID --field_id=$FIELD_ID --value="$META_VALUE"
    echo "Updated profile field $FIELD_ID for user $USER_ID."
  else
    echo "No meta value found for key '$META_KEY' for user $USER_ID. Skipping."
  fi
done

echo "Profile field sync complete."

How to Use:

  1. Save the file as sync_profile_field.sh.

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

  3. Run it with the source meta key and the destination BuddyBoss field ID: ./sync_profile_field.sh “registration_city” 5. (You can find the profile field ID in the BuddyBoss > Profiles section of your dashboard).