Resolve checkout level so level-restricted field groups show on signup form#74
Open
dwanjuki wants to merge 1 commit into
Open
Resolve checkout level so level-restricted field groups show on signup form#74dwanjuki wants to merge 1 commit into
dwanjuki wants to merge 1 commit into
Conversation
…p form PMPro filters restricted user-field groups against pmpro_getLevelAtCheckout(), which derives the level from the request (not the $pmpro_level global). On a signup-shortcode page there was no level in the request, so it fell back to the default/lowest level and level-restricted field groups were filtered out. Set $_REQUEST['pmpro_level'] to the shortcode's level before the checkout hooks fire so field-group resolution matches the form. Co-Authored-By: Claude Opus 4.8 (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.
All Submissions:
Changes proposed in this Pull Request:
When the Signup Shortcode renders a form for a level, User Field groups that are restricted to that level were not appearing, even though they appear on the level's normal checkout page.
The cause is that PMPro resolves which field groups to display via
pmpro_getLevelAtCheckout()(used byPMPro_Field_Group::get_fields_to_display()and the legacypmpro_checkout_boxes_fields()). That function ignores the$pmpro_levelglobal the shortcode sets and instead reads the level from the request —$_REQUEST['pmpro_level'], then the legacy$_REQUEST['level'], then the post's default-level meta, then the lowest level ID.On a signup shortcode page, there is no level in the request, so it fell back to the default/lowest level and any group restricted to a different level was filtered out.
This PR populates
$_REQUEST['pmpro_level']with the shortcode's level before thepmpro_checkout_preheaderand field hooks fire, so field group resolution matches the rest of the form (hidden level input, title, cost). It is set in single level mode only; multi level mode already disablescustom_fields.How to test the changes in this Pull Request:
[pmpro_signup level="X"]on a page, whereXis that restricted level, and view the page — the restricted group's fields now appear.[pmpro_signup level="Y"]for a different levelYand confirm the group does not appear (the restriction is still enforced, not always-on).Other information:
Changelog entry