feat(providers): add BuddyBossProfileTypeProvider (v1.4.0) - #13
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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", …)bp_get_member_types( [], 'objects' )— both admin-created Profile Types and code-registered types viabp_register_member_type()show up automaticallybp_get_member_type($uid, false)) intersects any selected slug — mirrorsWpRoleProvider's ANY semanticswpb_access_control_bb_profile_type_optionsandwpb_access_control_bb_profile_type_has_accessBuddyBoss-inactive safety
Every code path guards behind
is_available()(afunction_exists()check on the two BuddyBoss entry points). When the plugin is inactive:/providerspayload reportsavailable: false→ the ReactProviderDropdownhides the entry automaticallyget_options()returns[](no stale slugs leak through)user_has_access()denies (never grants against a missing API)Changes
src/BuddyBossProfileTypeProvider.php— new provider classsrc/AccessControlManager.php— registered alongsidewp_role/wp_user/wp_capabilityjs/components/RoleOptionsPanel.js— UI subtitle forbb_profile_typetests/Unit/BuddyBossProfileTypeProviderTest.php— 22 new testsassets/build/index.js— rebuilt viawp-scripts buildREADME.md/CHANGELOG.md— documentedTest plan
composer test— 138 tests / 195 assertions, all greennpm run build— wp-scripts compiles cleanly/providersreportsavailable: false, existingbb_profile_typerules deny🤖 Generated with Claude Code