Fix WP Approve User integration for v12+ three-state meta - #48
Open
obenland wants to merge 1 commit into
Open
Conversation
WP Approve User v12 switched the `wp-approve-user` user meta from a boolean to a three-state string: 'approved', 'pending', or 'unapproved'. The existing `is_pending()` check tests the meta with `! get_user_meta(...)`, which only worked when the stored value was the legacy boolean. Every v12+ string is truthy, so pending and unapproved users now appear approved and gain access to restricted content. Compare the stored value against both the canonical v12+ strings and the legacy `'1'` representation pre-v12 installs still hold, so the check works on every WP Approve User version.
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
WP Approve User v12 switched the
wp-approve-useruser meta from a boolean to a three-state string:'approved','pending', or'unapproved'. The integration'sis_pending()check atcore/includes/integrations/class-rcp-wp-approve-user.php:63still treats the meta as a boolean:Every v12+ string is truthy, so
! $metais alwaysfalse. Pending and unapproved users surface as approved and gain access to content that should be restricted.Fix
Compare the stored value against the canonical v12+ string (
'approved') and the legacy'1'boolean still present on pre-v12 installs. Anything else is treated as pending. This is forward- and backward-compatible across WP Approve User versions.Test plan
'pending'), log in as that user, and confirm they cannot view content gated by[restrict]or post-level RCP restrictions.'unapproved') and confirm they are blocked from restricted content on next page load.'1'and empty-string code paths must keep functioning.