Skip to content

Block and widget role restrictions: use payment-aware roles - #55

Merged
polevaultweb merged 2 commits into
masterfrom
fix/payment-aware-roles
Nov 3, 2026
Merged

polevaultweb merged 2 commits into
masterfrom
fix/payment-aware-roles

Conversation

@polevaultweb

@polevaultweb polevaultweb commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

The "Show block by user role" restriction, and the same setting on legacy widgets, compared the allowed roles with $current_user->roles. Core's shortcode and Elementor restrictions use wpum_get_user_access_roles() instead, which integrations filter (wpum_user_access_roles). The Stripe integration returns no roles there while an account still owes a payment, so a user who registered on a paid form and never paid could see blocks and widgets restricted to their role, while the shortcode next to them stayed hidden.

Changes

  • maybe_restrict_content() and maybe_restrict_widget() use wpum_get_user_access_roles( $current_user ). No function_exists() guard: php-scoper prefixes the name inside it, so in core's vendor-dist it was always false. The file already calls core functions unguarded, and core pins this package's version.

Tests

wpum-blocks has no suite. The tests are in core's tests/wpunit/Stripe/UnpaidCapabilitiesTest.php, which runs against this package once core requires the new tag.

Reported by elba.code via Patchstack.

🤖 Generated with Claude Code

Core's wpum_get_user_access_roles() lets integrations withhold roles,
e.g. Stripe while a payment is outstanding. The block and legacy widget
role checks read $user->roles directly, so an account that hadn't paid
still saw content restricted to its role.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
php-scoper prefixes the name inside function_exists(), so in core's
vendor-dist the guard was always false and the raw roles were used.
This file already calls core functions unguarded, and core pins the
wpum-blocks version, so the guard isn't needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@polevaultweb
polevaultweb merged commit 78f6530 into master Nov 3, 2026
@polevaultweb
polevaultweb deleted the fix/payment-aware-roles branch November 3, 2026 11:41
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