pmpro-register-helper
pmpro-register-helper copied to clipboard
Select2 script and style not enqueued if level parameter not present
Describe the bug
A select2 Register Helper field type is rendered as a multi-select field and the console has a javascript error notification of select2 not being a valid function when there is no level
URL parameter.
We should consider additional conditional checks if the user is on the checkout page to load the required CSS & JS here:
https://github.com/strangerstudios/pmpro-register-helper/blob/2780df68cde584b5087ad7b508aa68a84494046c/pmpro-register-helper.php#L1338-L1352
To Reproduce Steps to reproduce the behavior:
- Create a select2 RH field in a customization plugin.
- Navigate to the membership levels page and select any level
- Confirm on the checkout page that the select2 field is rendered as expected.
- Remove URL parameter level, e.g.
level=1
, and load page - Confirm that the select2 field is rendered as a multi-select field type
- Open the browser's developer tools and confirm that select2 CSS and JS files are not loaded.
Screenshots If applicable, please attach a screenshot to make your issue clearer.
Expected behavior A clear and concise description of what you expected to happen.
Isolating the problem (mark completed items with an [x]):
- [x] I have deactivated other plugins and confirmed this bug occurs when only Paid Memberships Pro plugin is active.
- [x] This bug happens with a default WordPress theme active, or Memberlite.
- [x] I can reproduce this bug consistently using the steps above.