Add llms_can_user_bypass_restrictions filter for custom role bypass - #3271
Open
faisalahammad wants to merge 1 commit into
Open
Add llms_can_user_bypass_restrictions filter for custom role bypass#3271faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Custom and third-party roles (e.g. Memberium, User Role Editor) added to Unrestricted Preview Access could not bypass enrollment, drip, and prerequisite restrictions because the edit_post capability gate blocks roles lacking that cap. Adds a pre_ short-circuit filter at the top of llms_can_user_bypass_restrictions() so developers can opt custom roles in. Default null preserves existing behavior. Returns boolean to override all internal checks. Fixes gocodebox#2180
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.
Description
Add the
llms_can_user_bypass_restrictionsfilter tollms_can_user_bypass_restrictions()so custom and third-party roles (e.g. Memberium, User Role Editor) added to Unrestricted Preview Access can bypass enrollment, drip, and prerequisite restrictions.The
edit_postcapability gate added in #1987 blocks roles that lack that capability. The filter gives developers an opt-in escape hatch. Defaultnullpreserves the existing behavior, including the #1974 security fix.Fixes #2180
How has this been tested?
composer tests -- --filter=test_llms_can_user_bypass_restrictionspasses (29 assertions across 3 methods including 2 new filter tests).composer check-csclean.TESTING_INSTRUCTIONS.md.Environment: LifterLMS dev environment, WordPress 6.x, PHP 7.4+.
Types of changes
Checklist: