Skip to content

feat(providers): add BuddyBossProfileTypeProvider (v1.4.0) - #13

Merged
raftaar1191 merged 1 commit into
mainfrom
release/v1.4.0
Jun 17, 2026
Merged

raftaar1191 merged 1 commit into
mainfrom
release/v1.4.0

Conversation

@raftaar1191

Copy link
Copy Markdown
Contributor

Summary

  • Adds a fourth built-in provider, BuddyBossProfileTypeProvider (bb_profile_type), so the React UI's Who can access dropdown can gate a resource by one or more BuddyBoss profile types ("Customer", "Vendor", "Partner", …)
  • Discovers options via bp_get_member_types( [], 'objects' ) — both admin-created Profile Types and code-registered types via bp_register_member_type() show up automatically
  • Access is granted when the user's profile-type list (bp_get_member_type($uid, false)) intersects any selected slug — mirrors WpRoleProvider's ANY semantics
  • Two new filters expose curation points: wpb_access_control_bb_profile_type_options and wpb_access_control_bb_profile_type_has_access

BuddyBoss-inactive safety

Every code path guards behind is_available() (a function_exists() check on the two BuddyBoss entry points). When the plugin is inactive:

  • REST /providers payload reports available: false → the React ProviderDropdown hides the entry automatically
  • get_options() returns [] (no stale slugs leak through)
  • user_has_access() denies (never grants against a missing API)

Changes

  • src/BuddyBossProfileTypeProvider.php — new provider class
  • src/AccessControlManager.php — registered alongside wp_role / wp_user / wp_capability
  • js/components/RoleOptionsPanel.js — UI subtitle for bb_profile_type
  • tests/Unit/BuddyBossProfileTypeProviderTest.php — 22 new tests
  • assets/build/index.js — rebuilt via wp-scripts build
  • README.md / CHANGELOG.md — documented

Test plan

  • composer test — 138 tests / 195 assertions, all green
  • npm run build — wp-scripts compiles cleanly
  • Smoke test with BuddyBoss active: dropdown shows BuddyBoss Profile Type, save a rule, assign user to type, verify access flips
  • Smoke test with BuddyBoss inactive: option hidden from dropdown, REST /providers reports available: false, existing bb_profile_type rules deny
  • CI matrix passes on PHP 8.1 – 8.5

🤖 Generated with Claude Code

Gates resources by one or more BuddyBoss profile types (member types).
Options are sourced from bp_get_member_types() and labels come from
$type->labels['singular_name'] with a slug fallback. Access is granted when
the requesting user's profile-type list (bp_get_member_type($uid, false))
intersects any selected slug.

The provider depends on the BuddyBoss Platform plugin. Every method guards
its API calls behind is_available() (function_exists check on the two
BuddyBoss entry points), so:

- The React /providers payload reports available: false when BuddyBoss is
  inactive — ProviderDropdown already hides unavailable entries.
- get_options() short-circuits to [] when unavailable so no stale slugs
  leak into the UI.
- user_has_access() denies when unavailable — never grants access against
  a missing API.

Files:
- src/BuddyBossProfileTypeProvider.php — new provider class with two
  filters (wpb_access_control_bb_profile_type_options,
   wpb_access_control_bb_profile_type_has_access).
- src/AccessControlManager.php — registered as a default provider.
- js/components/RoleOptionsPanel.js — description string for
  bb_profile_type; existing checkbox panel renders the new options.
- tests/Unit/BuddyBossProfileTypeProviderTest.php — 22 new tests covering
  identity, is_available, get_options (unavailability guard, label
  fallback, alphabetical sort, filter override) and user_has_access
  (unavailability guard, empty options, no user types, intersect match,
  filter override, strict comparison).
- README.md / CHANGELOG.md — documented new provider and filters.

PHPUnit: 138 tests / 195 assertions all green. JS assets rebuilt via
wp-scripts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@raftaar1191
raftaar1191 merged commit 9b06631 into main Jun 17, 2026
5 checks passed
@raftaar1191
raftaar1191 deleted the release/v1.4.0 branch June 17, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant