BuddyPress Profile Template (ORB)

Custom WordPress theme file · drafted 07 October 2026 (Wednesday, UTC). The BuddyPress profile template that extends BuddyPress's default profile with the ORB operation's per-member fields. Member type, region, BuddyPro ID, AffiliateWP tag, top-ten customer list, charity preferences, BP accounting, JOKE of the WEEK subscription, product reviews, face-pop video, soft-upsell tier. Operator uploads the file to the WordPress theme directory; activates; the template renders the ORB operation's per-member profile surface.

What this page is. The custom WordPress theme file (`/buddypress/members/single/profile.php`) that overrides BuddyPress's default profile. The template renders the ORB operation's per-member fields. Operator-side: upload the file to the WordPress theme directory; activate; the template renders. Agent-side: this page is the template's content; the operator copies the PHP code into the theme file.

1. The template file location

WordPress themes can override BuddyPress's default templates. The custom profile template lives at:

/wp-content/themes/{your-theme}/buddypress/members/single/profile.php

Operator-side setup:

  1. Create the directory structure in the active WordPress theme: /buddypress/members/single/.
  2. Create the file profile.php in that directory.
  3. Paste the PHP code below into the file.
  4. Save the file. WordPress will use this template instead of BuddyPress's default profile template.

2. The PHP code (the custom template)

The custom profile template renders the ORB operation's per-member fields. Copy this into profile.php:

<?php
/**
 * ORB BuddyPress Profile Template
 * Overrides BuddyPress's default profile template.
 * Drafted 07 October 2026 (UTC).
 *
 * Renders the ORB operation's per-member fields:
 * - Member type (vet, dentist, salon, etc.)
 * - Region (Calgary, Toronto, Dallas, etc.)
 * - BuddyPro ID
 * - AffiliateWP tag
 * - Top-ten customer list
 * - Charity preferences (per Per-Member Charity Preferences)
 * - BP accounting (per-customer / per-project / cumulative)
 * - JOKE of the WEEK subscription
 * - Product reviews
 * - Face-Pop video
 * - Soft-upsell tier (per Add-On Services Library)
 *
 * Loads the ORB design language CSS (matches the operation's palette).
 */
get_header();
?>

<div class="orb-profile-wrap">
  <div class="orb-profile-header">
    <?php
    // Avatar (BuddyPress default).
    bp_displayed_user_avatar( 'type=full' );
    ?>
    <h1 class="orb-profile-name"><?php bp_displayed_user_fullname(); ?></h1>
    <div class="orb-profile-meta">
      <?php
      // Member type (BuddyPress member type).
      $member_type = bp_get_member_type( bp_displayed_user_id() );
      if ( $member_type ) {
        echo '<span class="orb-member-type">' . esc_html( $member_type ) . '</span>';
      }
      // Region (custom field).
      $region = get_user_meta( bp_displayed_user_id(), 'orb_member_region', true );
      if ( $region ) {
        echo '<span class="orb-region">' . esc_html( $region ) . '</span>';
      }
      ?>
    </div>
  </div>

  <div class="orb-profile-body">
    <h2>Member info</h2>
    <?php
    // BuddyPro ID.
    $buddypro_id = get_user_meta( bp_displayed_user_id(), 'orb_buddypro_id', true );
    if ( $buddypro_id ) {
      echo '<p><strong>BuddyPro ID:</strong> ' . esc_html( $buddypro_id ) . '</p>';
    }
    // AffiliateWP tag.
    $affwp_tag = get_user_meta( bp_displayed_user_id(), 'orb_affwp_tag', true );
    if ( $affwp_tag ) {
      echo '<p><strong>AffiliateWP tag:</strong> ' . esc_html( $affwp_tag ) . '</p>';
    }
    ?>

    <h2>Charity preferences</h2>
    <?php
    // Per-member charity allocations (per Per-Member Charity Preferences).
    $charity_pref = get_user_meta( bp_displayed_user_id(), 'orb_charity_preferences', true );
    if ( $charity_pref ) {
      echo '<ul class="orb-charity-list">';
      foreach ( $charity_pref as $charity_id => $percentage ) {
        $charity_name = get_post_field( 'post_title', $charity_id );
        echo '<li>' . esc_html( $charity_name ) . ': ' . esc_html( $percentage ) . '%</li>';
      }
      echo '</ul>';
    } else {
      echo '<p>No charity preferences set. <a href="' . bp_displayed_user_domain() . 'charity-preferences/">Set preferences</a>.</p>';
    }
    ?>

    <h2>Brownie Points (BP) accounting</h2>
    <?php
    // Per-customer / per-project / cumulative BP accounting.
    // References the BP-as-Discount Architecture on the durable record.
    $bp_per_customer = get_user_meta( bp_displayed_user_id(), 'orb_bp_per_customer', true );
    $bp_per_project = get_user_meta( bp_displayed_user_id(), 'orb_bp_per_project', true );
    $bp_cumulative = get_user_meta( bp_displayed_user_id(), 'orb_bp_cumulative', true );
    if ( $bp_cumulative ) {
      echo '<p><strong>Per-customer:</strong> ' . esc_html( $bp_per_customer ?: '0' ) . ' BP</p>';
      echo '<p><strong>Per-project:</strong> ' . esc_html( $bp_per_project ?: '0' ) . ' BP</p>';
      echo '<p><strong>Cumulative:</strong> ' . esc_html( $bp_cumulative ) . ' BP</p>';
    } else {
      echo '<p>No BP accounting yet.</p>';
    }
    ?>

    <h2>JOKE of the WEEK subscription</h2>
    <?php
    // JOKE-of-the-DAY / EMPOWER-of-the-DAY subscription (per the Per-Project Portal Archive).
    $joke_subscribed = get_user_meta( bp_displayed_user_id(), 'orb_joke_subscribed', true );
    if ( $joke_subscribed ) {
      echo '<p>Subscribed to JOKE of the WEEK.</p>';
    } else {
      echo '<p>Not subscribed. <a href="' . bp_displayed_user_domain() . 'joke-subscribe/">Subscribe</a>.</p>';
    }
    ?>

    <h2>Product reviews received</h2>
    <?php
    // Product reviews (per the Product Review Form).
    $reviews = get_user_meta( bp_displayed_user_id(), 'orb_product_reviews', true );
    if ( $reviews ) {
      echo '<ul class="orb-review-list">';
      foreach ( $reviews as $review ) {
        echo '<li>';
        echo '<strong>Grade:</strong> ' . esc_html( $review['grade'] ) . '/5 &middot; ';
        echo '<strong>Project:</strong> ' . esc_html( $review['project'] ) . '<br>';
        echo esc_html( $review['text'] );
        echo '</li>';
      }
      echo '</ul>';
    } else {
      echo '<p>No reviews yet.</p>';
    }
    ?>

    <h2>Face-Pop video</h2>
    <?php
    // Face-Pop video (per the Face-Pop Video Widget page).
    $facepop_url = get_user_meta( bp_displayed_user_id(), 'orb_facepop_video_url', true );
    if ( $facepop_url ) {
      echo '<video controls><source src="' . esc_url( $facepop_url ) . '"></video>';
    } else {
      echo '<p>No video recorded yet. <a href="' . bp_displayed_user_domain() . 'record-video/">Record a video</a>.</p>';
    }
    ?>

    <h2>Add-on services (soft-upsell)</h2>
    <?php
    // Soft-upsell tier (per the Add-On Services Library).
    $upsell_tier = get_user_meta( bp_displayed_user_id(), 'orb_upsell_tier', true );
    if ( $upsell_tier ) {
      echo '<p><strong>Tier:</strong> ' . esc_html( $upsell_tier ) . '</p>';
      // Per-tier add-on services.
      $addons = get_user_meta( bp_displayed_user_id(), 'orb_upsell_addons', true );
      if ( $addons ) {
        echo '<ul class="orb-addon-list">';
        foreach ( $addons as $addon ) {
          echo '<li>' . esc_html( $addon['name'] ) . ' &middot; ' . esc_html( $addon['description'] ) . ' &middot; ' . esc_html( $addon['price'] ) . '</li>';
        }
        echo '</ul>';
      }
    } else {
      echo '<p>No add-ons at this tier.</p>';
    }
    ?>

    <h2>Top-ten customer list</h2>
    <?php
    // Top-ten customer list (per the Top-Ten Customer Input Form).
    $top_ten = get_user_meta( bp_displayed_user_id(), 'orb_top_ten_customers', true );
    if ( $top_ten ) {
      echo '<ol class="orb-top-ten-list">';
      foreach ( $top_ten as $customer ) {
        echo '<li>' . esc_html( $customer['name'] ) . ' &middot; ' . esc_html( $customer['relationship'] ) . '</li>';
      }
      echo '</ol>';
    } else {
      echo '<p>Top-ten customer list not yet populated.</p>';
    }
    ?>

    <h2>Recent activity</h2>
    <?php
    // BuddyPress activity stream.
    if ( bp_activity_has_items() ) {
      while ( bp_activities() ) {
        bp_the_activity();
        bp_activity_action();
        bp_activity_content_body();
      }
    } else {
      echo '<p>No recent activity.</p>';
    }
    ?>
  </div>
</div>

<?php get_footer(); ?>

3. The custom fields (per-member data)

The template reads from WordPress user meta fields. Each member has these custom fields. The operator populates them via WordPress admin or via the custom forms built in this session:

User meta keyFieldSource
orb_member_regionRegion (Calgary / Toronto / Dallas / etc.)Operator-side population
orb_buddypro_idBuddyPro account IDAuto-populated on BuddyPro account creation
orb_affwp_tagAffiliateWP tagAuto-populated on AffiliateWP account creation
orb_charity_preferencesPer-member charity allocations (array of charity_id => percentage)Per-Member Charity Preferences
orb_bp_per_customerBP per-customer countBP accounting custom plugin
orb_bp_per_projectBP per-project countBP accounting custom plugin
orb_bp_cumulativeBP cumulative countBP accounting custom plugin
orb_joke_subscribedJOKE of the WEEK subscription (boolean)Per-Project Portal Archive subscription form
orb_product_reviewsProduct reviews (array of grade / project / text / observations)Product Review Form
orb_facepop_video_urlFace-Pop video URLFace-Pop Video Widget
orb_upsell_tierSoft-upsell tier (Bronze / Silver / Gold)Add-On Services Library
orb_upsell_addonsPer-tier add-on services (array of name / description / price)Add-On Services Library
orb_top_ten_customersTop-ten customer list (array of name / relationship)Top-Ten Customer Input Form

4. The ORB design language CSS (matching the operation's palette)

The custom template uses the ORB design language. Add the CSS to the active WordPress theme's style.css or to a custom CSS file:

/* ORB Design Language — BuddyPress Profile Template */

:root {
  --orb-primary: #272c68;       /* deep blue — Chief Architect */
  --orb-accent: #c8a96a;        /* warm gold */
  --orb-bg: #fafaf6;            /* warm cream */
  --orb-card: #ffffff;
  --orb-line: #d4c8a8;
  --orb-ink: #1a1a1a;
  --orb-ink-soft: #666;
}

.orb-profile-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px;
  background: var(--orb-bg);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.65;
  font-size: 16px;
  color: var(--orb-ink);
}

.orb-profile-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  background: var(--orb-card);
  border: 1px solid var(--orb-line);
  border-left: 5px solid var(--orb-primary);
  border-radius: 6px;
  padding: 18px 22px;
  margin-bottom: 18px;
}

.orb-profile-name {
  font-size: 24px;
  color: var(--orb-primary);
  font-weight: bold;
  margin: 0;
}

.orb-profile-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--orb-ink-soft);
}

.orb-member-type, .orb-region {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--orb-primary);
  color: var(--orb-accent);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.orb-profile-body {
  background: var(--orb-card);
  border: 1px solid var(--orb-line);
  border-radius: 6px;
  padding: 18px 22px;
}

.orb-profile-body h2 {
  font-size: 20px;
  margin-top: 24px;
  border-left: 4px solid var(--orb-primary);
  padding-left: 12px;
  color: var(--orb-primary);
}

.orb-profile-body h2:first-child {
  margin-top: 0;
}

.orb-charity-list, .orb-review-list, .orb-addon-list, .orb-top-ten-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.orb-charity-list li, .orb-review-list li, .orb-addon-list li, .orb-top-ten-list li {
  background: #fdf6e3;
  border-left: 3px solid var(--orb-accent);
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 0 4px 4px 0;
  font-size: 14px;
}

@media (max-width: 600px) {
  .orb-profile-wrap { padding: 18px; font-size: 15px; }
  .orb-profile-header { grid-template-columns: 1fr; text-align: center; }
  .orb-profile-meta { justify-content: center; }
}

5. The custom plugin (BP accounting + custom fields registration)

A companion WordPress plugin registers the custom fields and the BP accounting. Create a file at /wp-content/plugins/orb-bp-accounting/orb-bp-accounting.php:

<?php
/**
 * Plugin Name: ORB BP Accounting
 * Description: Registers ORB operation's per-member custom fields + BP accounting.
 * Version: 1.0
 * Author: ORB Operator
 */

if ( ! defined( 'ABSPATH' ) ) { exit; }

// Register custom fields on user profile.
add_action( 'show_user_profile', 'orb_member_custom_fields' );
add_action( 'edit_user_profile', 'orb_member_custom_fields' );
function orb_member_custom_fields( $user ) {
  if ( ! current_user_can( 'edit_user', $user->ID ) ) { return; }
  $buddypro_id = get_user_meta( $user->ID, 'orb_buddypro_id', true );
  $affwp_tag = get_user_meta( $user->ID, 'orb_affwp_tag', true );
  $region = get_user_meta( $user->ID, 'orb_member_region', true );
  $upsell_tier = get_user_meta( $user->ID, 'orb_upsell_tier', true );
  ?>
  <h3>ORB Member Info</h3>
  <table class="form-table">
    <tr>
      <th><label for="orb_buddypro_id">BuddyPro ID</label></th>
      <td><input type="text" name="orb_buddypro_id" value="<?php echo esc_attr( $buddypro_id ); ?>" class="regular-text" /></td>
    </tr>
    <tr>
      <th><label for="orb_affwp_tag">AffiliateWP tag</label></th>
      <td><input type="text" name="orb_affwp_tag" value="<?php echo esc_attr( $affwp_tag ); ?>" class="regular-text" /></td>
    </tr>
    <tr>
      <th><label for="orb_member_region">Region</label></th>
      <td>
        <select name="orb_member_region">
          <option value="">Select region</option>
          <option value="Calgary" <?php selected( $region, 'Calgary' ); ?>>Calgary</option>
          <option value="Toronto" <?php selected( $region, 'Toronto' ); ?>>Toronto</option>
          <option value="Dallas" <?php selected( $region, 'Dallas' ); ?>>Dallas</option>
          <option value="Pacific-Northwest" <?php selected( $region, 'Pacific-Northwest' ); ?>>Pacific-Northwest</option>
          <option value="Mountain" <?php selected( $region, 'Mountain' ); ?>>Mountain</option>
          <option value="Midwest" <?php selected( $region, 'Midwest' ); ?>>Midwest</option>
          <option value="Atlantic" <?php selected( $region, 'Atlantic' ); ?>>Atlantic</option>
          <option value="International" <?php selected( $region, 'International' ); ?>>International</option>
        </select>
      </td>
    </tr>
    <tr>
      <th><label for="orb_upsell_tier">Soft-upsell tier</label></th>
      <td>
        <select name="orb_upsell_tier">
          <option value="">Select tier</option>
          <option value="Bronze" <?php selected( $upsell_tier, 'Bronze' ); ?>>Bronze</option>
          <option value="Silver" <?php selected( $upsell_tier, 'Silver' ); ?>>Silver</option>
          <option value="Gold" <?php selected( $upsell_tier, 'Gold' ); ?>>Gold</option>
        </select>
      </td>
    </tr>
  </table>
  <?php
}

// Save custom fields.
add_action( 'personal_options_update', 'orb_member_save_custom_fields' );
add_action( 'edit_user_profile_update', 'orb_member_save_custom_fields' );
function orb_member_save_custom_fields( $user_id ) {
  if ( ! current_user_can( 'edit_user', $user_id ) ) { return; }
  if ( isset( $_POST['orb_buddypro_id'] ) ) {
    update_user_meta( $user_id, 'orb_buddypro_id', sanitize_text_field( $_POST['orb_buddypro_id'] ) );
  }
  if ( isset( $_POST['orb_affwp_tag'] ) ) {
    update_user_meta( $user_id, 'orb_affwp_tag', sanitize_text_field( $_POST['orb_affwp_tag'] ) );
  }
  if ( isset( $_POST['orb_member_region'] ) ) {
    update_user_meta( $user_id, 'orb_member_region', sanitize_text_field( $_POST['orb_member_region'] ) );
  }
  if ( isset( $_POST['orb_upsell_tier'] ) ) {
    update_user_meta( $user_id, 'orb_upsell_tier', sanitize_text_field( $_POST['orb_upsell_tier'] ) );
  }
}

// BP accounting: cumulative BP counter.
add_action( 'orb_bp_event', 'orb_bp_update_cumulative', 10, 2 );
function orb_bp_update_cumulative( $user_id, $delta ) {
  $current = (int) get_user_meta( $user_id, 'orb_bp_cumulative', true );
  $new = $current + $delta;
  update_user_meta( $user_id, 'orb_bp_cumulative', $new );
  return $new;
}

// Helper function: trigger a BP event.
function orb_bp_event( $user_id, $delta ) {
  do_action( 'orb_bp_event', $user_id, $delta );
}

6. Status

What is in place today (07 October 2026):
What is NOT in place today:


7. Cross-Site AffiliateWP API integration (added 07 October 2026 — extends the BuddyPress Profile Template for two-site architecture)

Operator named: AffiliateWP Pro is already installed on orb-business; orb-commons.com is a separate WordPress site for BuddyPress. The two-site architecture requires AffiliateWP data to be fetched from orb-business via API, not stored locally as user meta. This section updates the BuddyPress Profile Template accordingly.

The change. The AffiliateWP-related fields (affiliate tag, commission rate, referral count, cumulative commissions, pending payouts) are now fetched from orb-business's AffiliateWP Pro REST API. The BP accounting remains local (per-customer / per-project / cumulative; references the BP-as-Discount Architecture on the durable record). Charity preferences, JOKE subscriptions, product reviews, Face-Pop video, soft-upsell tier, and top-ten customer list remain local.

7.1 The AffiliateWP API client (companion plugin)

A companion WordPress plugin on orb-commons.com wraps the AffiliateWP API calls. Create the file at /wp-content/plugins/orb-affwp-client/orb-affwp-client.php:

<?php
/**
 * Plugin Name: ORB AffiliateWP Client
 * Description: Wraps AffiliateWP Pro REST API calls from orb-commons.com to orb-business.
 * Version: 1.0
 * Author: ORB Operator
 */

if ( ! defined( 'ABSPATH' ) ) { exit; }

class ORB_AffiliateWP_Client {
  private $api_base;
  private $api_key;

  public function __construct() {
    // API base and key from wp-config.php.
    $this->api_base = defined( 'ORB_AFFWP_API_BASE' ) ? ORB_AFFWP_API_BASE : '';
    $this->api_key = defined( 'ORB_AFFWP_API_KEY' ) ? ORB_AFFWP_API_KEY : '';
  }

  // Get affiliate data by user_id.
  public function get_affiliate_by_user( $user_id ) {
    $cache_key = 'orb_affwp_affiliate_' . $user_id;
    $cached = get_transient( $cache_key );
    if ( $cached !== false ) { return $cached; }
    if ( ! $this->api_base || ! $this->api_key ) { return null; }
    $url = $this->api_base . '/affiliates?user_id=' . intval( $user_id );
    $response = wp_remote_get( $url, array(
      'headers' => array(
        'Authorization' => 'Basic ' . base64_encode( $this->api_key . ':' ),
      ),
      'timeout' => 15,
    ));
    if ( is_wp_error( $response ) ) { return null; }
    $body = json_decode( wp_remote_retrieve_body( $response ), true );
    $affiliate = isset( $body['affiliates'][0] ) ? $body['affiliates'][0] : null;
    if ( $affiliate ) {
      set_transient( $cache_key, $affiliate, HOUR_IN_SECONDS );
    }
    return $affiliate;
  }

  // Get referrals by affiliate_id.
  public function get_referrals_by_affiliate( $affiliate_id, $limit = 10 ) {
    $cache_key = 'orb_affwp_referrals_' . $affiliate_id;
    $cached = get_transient( $cache_key );
    if ( $cached !== false ) { return $cached; }
    if ( ! $this->api_base || ! $this->api_key ) { return null; }
    $url = $this->api_base . '/referrals?affiliate_id=' . intval( $affiliate_id ) . '&number=' . intval( $limit );
    $response = wp_remote_get( $url, array(
      'headers' => array(
        'Authorization' => 'Basic ' . base64_encode( $this->api_key . ':' ),
      ),
      'timeout' => 15,
    ));
    if ( is_wp_error( $response ) ) { return null; }
    $body = json_decode( wp_remote_retrieve_body( $response ), true );
    $referrals = isset( $body['referrals'] ) ? $body['referrals'] : array();
    set_transient( $cache_key, $referrals, HOUR_IN_SECONDS );
    return $referrals;
  }

  // Create an affiliate on orb-business when a new member signs up on orb-commons.com.
  public function create_affiliate( $user_id, $referral_format, $rate, $payment_email ) {
    if ( ! $this->api_base || ! $this->api_key ) { return null; }
    $url = $this->api_base . '/affiliates';
    $response = wp_remote_post( $url, array(
      'headers' => array(
        'Authorization' => 'Basic ' . base64_encode( $this->api_key . ':' ),
        'Content-Type' => 'application/json',
      ),
      'body' => json_encode( array(
        'user_id' => intval( $user_id ),
        'referral_format' => sanitize_text_field( $referral_format ),
        'rate' => floatval( $rate ),
        'rate_type' => 'percentage',
        'payment_email' => sanitize_email( $payment_email ),
        'status' => 'active',
      )),
      'timeout' => 15,
    ));
    if ( is_wp_error( $response ) ) { return null; }
    $body = json_decode( wp_remote_retrieve_body( $response ), true );
    delete_transient( 'orb_affwp_affiliate_' . $user_id );
    return $body;
  }

  // Create a referral on orb-business when a customer makes a purchase via the member's link.
  public function create_referral( $affiliate_id, $reference, $description, $amount ) {
    if ( ! $this->api_base || ! $this->api_key ) { return null; }
    $url = $this->api_base . '/referrals';
    $response = wp_remote_post( $url, array(
      'headers' => array(
        'Authorization' => 'Basic ' . base64_encode( $this->api_key . ':' ),
        'Content-Type' => 'application/json',
      ),
      'body' => json_encode( array(
        'affiliate_id' => intval( $affiliate_id ),
        'reference' => sanitize_text_field( $reference ),
        'description' => sanitize_text_field( $description ),
        'amount' => floatval( $amount ),
        'status' => 'pending',
      )),
      'timeout' => 15,
    ));
    if ( is_wp_error( $response ) ) { return null; }
    $body = json_decode( wp_remote_retrieve_body( $response ), true );
    delete_transient( 'orb_affwp_referrals_' . $affiliate_id );
    return $body;
  }
}

// Singleton accessor.
function orb_affwp_client() {
  static $client = null;
  if ( $client === null ) {
    $client = new ORB_AffiliateWP_Client();
  }
  return $client;
}

7.2 The updated BuddyPress profile template (cross-site AffiliateWP)

Replace the affiliate-related sections in /buddypress/members/single/profile.php with cross-site API calls:

<?php
/**
 * ORB BuddyPress Profile Template — Cross-Site AffiliateWP version
 * Replaces local user-meta reads with AffiliateWP API calls to orb-business.
 * Other fields (charity, BP, JOKE, product reviews, Face-Pop, soft-upsell, top-ten) remain local.
 */
get_header();
?>

<div class="orb-profile-wrap">
  <div class="orb-profile-header">
    <?php bp_displayed_user_avatar( 'type=full' ); ?>
    <h1 class="orb-profile-name"><?php bp_displayed_user_fullname(); ?></h1>
    <div class="orb-profile-meta">
      <?php
      $member_type = bp_get_member_type( bp_displayed_user_id() );
      if ( $member_type ) { echo '<span class="orb-member-type">' . esc_html( $member_type ) . '</span>'; }
      $region = get_user_meta( bp_displayed_user_id(), 'orb_member_region', true );
      if ( $region ) { echo '<span class="orb-region">' . esc_html( $region ) . '</span>'; }
      ?>
    </div>
  </div>

  <div class="orb-profile-body">
    <h2>Affiliate data (live from orb-business AffiliateWP Pro)</h2>
    <?php
    // Cross-site AffiliateWP API call.
    $affiliate = orb_affwp_client()->get_affiliate_by_user( bp_displayed_user_id() );
    if ( $affiliate ) {
      echo '<dl class="orb-affiliate-data">';
      echo '<dt>Affiliate tag:</dt><dd>' . esc_html( $affiliate['referral_format'] ) . '</dd>';
      echo '<dt>Commission rate:</dt><dd>' . esc_html( $affiliate['rate'] ) . '%</dd>';
      echo '<dt>Status:</dt><dd>' . esc_html( $affiliate['status'] ) . '</dd>';
      echo '<dt>Date registered:</dt><dd>' . esc_html( $affiliate['date_registered'] ) . '</dd>';
      // Cumulative earnings (from referrals).
      $referrals = orb_affwp_client()->get_referrals_by_affiliate( $affiliate['affiliate_id'], 100 );
      if ( $referrals ) {
        $total = 0;
        $pending = 0;
        foreach ( $referrals as $r ) {
          if ( $r['status'] === 'unpaid' || $r['status'] === 'paid' ) { $total += floatval( $r['amount'] ); }
          if ( $r['status'] === 'pending' || $r['status'] === 'unpaid' ) { $pending += floatval( $r['amount'] ); }
        }
        echo '<dt>Cumulative earnings:</dt><dd>$' . esc_html( number_format( $total, 2 ) ) . '</dd>';
        echo '<dt>Pending payouts:</dt><dd>$' . esc_html( number_format( $pending, 2 ) ) . '</dd>';
        echo '<dt>Total referrals:</dt><dd>' . count( $referrals ) . '</dd>';
      }
      echo '</dl>';
    } else {
      echo '<p>No AffiliateWP account linked. <a href="' . bp_displayed_user_domain() . 'affiliate-setup/">Set up affiliate</a>.</p>';
    }
    ?>

    <h2>Charity preferences</h2>
    <?php
    $charity_pref = get_user_meta( bp_displayed_user_id(), 'orb_charity_preferences', true );
    if ( $charity_pref ) {
      echo '<ul class="orb-charity-list">';
      foreach ( $charity_pref as $charity_id => $percentage ) {
        $charity_name = get_post_field( 'post_title', $charity_id );
        echo '<li>' . esc_html( $charity_name ) . ': ' . esc_html( $percentage ) . '%</li>';
      }
      echo '</ul>';
    } else {
      echo '<p>No charity preferences set.</p>';
    }
    ?>

    <h2>Brownie Points (BP) accounting (local)</h2>
    <?php
    $bp_per_customer = get_user_meta( bp_displayed_user_id(), 'orb_bp_per_customer', true );
    $bp_per_project = get_user_meta( bp_displayed_user_id(), 'orb_bp_per_project', true );
    $bp_cumulative = get_user_meta( bp_displayed_user_id(), 'orb_bp_cumulative', true );
    if ( $bp_cumulative ) {
      echo '<p><strong>Per-customer:</strong> ' . esc_html( $bp_per_customer ?: '0' ) . ' BP</p>';
      echo '<p><strong>Per-project:</strong> ' . esc_html( $bp_per_project ?: '0' ) . ' BP</p>';
      echo '<p><strong>Cumulative:</strong> ' . esc_html( $bp_cumulative ) . ' BP</p>';
    } else {
      echo '<p>No BP accounting yet.</p>';
    }
    ?>

    <h2>JOKE of the WEEK subscription</h2>
    <?php
    $joke_subscribed = get_user_meta( bp_displayed_user_id(), 'orb_joke_subscribed', true );
    echo $joke_subscribed ? '<p>Subscribed.</p>' : '<p>Not subscribed.</p>';
    ?>

    <h2>Product reviews received</h2>
    <?php
    $reviews = get_user_meta( bp_displayed_user_id(), 'orb_product_reviews', true );
    if ( $reviews ) {
      echo '<ul class="orb-review-list">';
      foreach ( $reviews as $review ) {
        echo '<li><strong>Grade:</strong> ' . esc_html( $review['grade'] ) . '/5 &middot; <strong>Project:</strong> ' . esc_html( $review['project'] ) . '<br>' . esc_html( $review['text'] ) . '</li>';
      }
      echo '</ul>';
    } else {
      echo '<p>No reviews yet.</p>';
    }
    ?>

    <h2>Face-Pop video</h2>
    <?php
    $facepop_url = get_user_meta( bp_displayed_user_id(), 'orb_facepop_video_url', true );
    if ( $facepop_url ) {
      echo '<video controls><source src="' . esc_url( $facepop_url ) . '"></video>';
    } else {
      echo '<p>No video recorded yet.</p>';
    }
    ?>

    <h2>Add-on services (soft-upsell)</h2>
    <?php
    $upsell_tier = get_user_meta( bp_displayed_user_id(), 'orb_upsell_tier', true );
    if ( $upsell_tier ) {
      echo '<p><strong>Tier:</strong> ' . esc_html( $upsell_tier ) . '</p>';
      $addons = get_user_meta( bp_displayed_user_id(), 'orb_upsell_addons', true );
      if ( $addons ) {
        echo '<ul class="orb-addon-list">';
        foreach ( $addons as $addon ) {
          echo '<li>' . esc_html( $addon['name'] ) . ' &middot; ' . esc_html( $addon['description'] ) . ' &middot; ' . esc_html( $addon['price'] ) . '</li>';
        }
        echo '</ul>';
      }
    } else {
      echo '<p>No add-ons at this tier.</p>';
    }
    ?>

    <h2>Top-ten customer list</h2>
    <?php
    $top_ten = get_user_meta( bp_displayed_user_id(), 'orb_top_ten_customers', true );
    if ( $top_ten ) {
      echo '<ol class="orb-top-ten-list">';
      foreach ( $top_ten as $customer ) {
        echo '<li>' . esc_html( $customer['name'] ) . ' &middot; ' . esc_html( $customer['relationship'] ) . '</li>';
      }
      echo '</ol>';
    } else {
      echo '<p>Top-ten customer list not yet populated.</p>';
    }
    ?>

    <h2>Recent activity</h2>
    <?php
    if ( bp_activity_has_items() ) {
      while ( bp_activities() ) {
        bp_the_activity();
        bp_activity_action();
        bp_activity_content_body();
      }
    } else {
      echo '<p>No recent activity.</p>';
    }
    ?>
  </div>
</div>

<?php get_footer(); ?>

7.3 The wp-config.php additions for orb-commons.com

Add these to the orb-commons.com's wp-config.php:

// ORB AffiliateWP Pro API endpoint (canonical on orb-business).
define( 'ORB_AFFWP_API_BASE', 'https://orb-business.com/wp-json/affiliatewp/v2' );
define( 'ORB_AFFWP_API_KEY', 'your-affiliatewp-api-key-here' );

// ORB JWT SSO secret (shared with orb-business).
define( 'ORB_JWT_SSO_SECRET', 'your-shared-jwt-secret-here' );

7.4 What stays local vs. what is cross-site

FieldStorageSource
Affiliate tagCross-site (API)AffiliateWP Pro on orb-business
Commission rateCross-site (API)AffiliateWP Pro on orb-business
Cumulative earningsCross-site (API; computed from referrals)AffiliateWP Pro on orb-business
Pending payoutsCross-site (API; computed from referrals)AffiliateWP Pro on orb-business
Total referralsCross-site (API; counted from referrals)AffiliateWP Pro on orb-business
Charity preferencesLocal (user meta)orb-commons.com BuddyPress
BP accounting (per-customer / per-project / cumulative)Local (user meta)orb-commons.com BuddyPress
JOKE of the WEEK subscriptionLocal (user meta)orb-commons.com BuddyPress
Product reviewsLocal (user meta)orb-commons.com BuddyPress
Face-Pop video URLLocal (user meta)orb-commons.com BuddyPress
Soft-upsell tier + add-onsLocal (user meta)orb-commons.com BuddyPress
Top-ten customer listLocal (user meta)orb-commons.com BuddyPress
BuddyPress member typeLocal (BuddyPress native)orb-commons.com BuddyPress
RegionLocal (user meta)orb-commons.com BuddyPress

7.5 What this section replaces in the prior template

The prior template (Section 3) referenced AffiliateWP data as local user meta (orb_affwp_tag). With the two-site architecture, those fields are fetched from orb-business via the AffiliateWP Pro API. The companion plugin orb-affwp-client wraps the API calls; the BuddyPress profile template calls orb_affwp_client()->get_affiliate_by_user($user_id) to retrieve the affiliate data; the template caches the response for 1 hour via WordPress transients to avoid API-rate-limit issues.