You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the pmpro_required_user_fields filter to unset required fields (such as username, password, and password2) on the checkout page, the corresponding pmpro_form_input-required class and the asterisk (pmpro_asterisk) indicating a required field are still applied in the HTML output. This behavior differs from the handling of billing fields (e.g., bphone, bzipcode), where the required status is correctly removed when using the pmpro_required_billing_fields filter.
To Reproduce
Steps to reproduce the behavior:
Add the following code to your theme or plugin to unset username and password fields as required:
Inspect the HTML output for the username and password fields.
Despite the fields being unset as required, the pmpro_form_input-required class and asterisk are still present, marking the fields as required.
Submitting the form with these fields empty results in successful submission, but the fields are falsely marked as required in the UI.
Expected behavior
When a field is unset using the pmpro_required_user_fields filter, the following should happen:
The pmpro_form_input-required class should be removed from the username and password fields.
The asterisk (pmpro_asterisk) indicating a required field should not appear.
The aria-required="true" attribute should be removed from these fields as well.
Currently, this works as expected for billing fields like bphone and bzipcode when using the pmpro_required_billing_fields filter, but not for user fields like username, password, and password2.
This block of code around line 152 in the file paid-memberships-pro/js/pmpro-checkout.js is responsible for incorrectly adding the required field asterisks to the fields which are no longer required:
jQuery('.pmpro_form_field-required').each(function() {
// Check if there's an asterisk already
var $firstLabel = jQuery(this).find('.pmpro_form_label').first();
var $hasAsterisk = $firstLabel.find('.pmpro_asterisk').length > 0;
// If there's no asterisk, add one
if ( ! $hasAsterisk ) {
$firstLabel.append('<span class="pmpro_asterisk"> <abbr title="Required Field">*</abbr></span>');
}
// Add the aria-required="true" attribute to the input.
jQuery(this).find('.pmpro_form_input').attr('aria-required', 'true');
});
Isolating the problem (mark completed items with an [x]):
I have deactivated other plugins and confirmed this bug occurs when only Paid Memberships Pro plugin is active.
This bug happens with a default WordPress theme active, or Memberlite.
I can reproduce this bug consistently using the steps above.
Describe the bug
When using the pmpro_required_user_fields filter to unset required fields (such as username, password, and password2) on the checkout page, the corresponding pmpro_form_input-required class and the asterisk (pmpro_asterisk) indicating a required field are still applied in the HTML output. This behavior differs from the handling of billing fields (e.g., bphone, bzipcode), where the required status is correctly removed when using the pmpro_required_billing_fields filter.
To Reproduce
Steps to reproduce the behavior:
add_filter('pmpro_required_user_fields', 'custom_remove_required_user_fields', 10, 1);
function custom_remove_required_user_fields($required_fields) {
unset($pmpro_required_user_fields['username']);
unset($pmpro_required_user_fields['password']);
unset($pmpro_required_user_fields['password2']);
return $pmpro_required_user_fields;
}
Expected behavior
When a field is unset using the pmpro_required_user_fields filter, the following should happen:
The pmpro_form_input-required class should be removed from the username and password fields.
The asterisk (pmpro_asterisk) indicating a required field should not appear.
The aria-required="true" attribute should be removed from these fields as well.
Currently, this works as expected for billing fields like bphone and bzipcode when using the pmpro_required_billing_fields filter, but not for user fields like username, password, and password2.
This block of code around line 152 in the file paid-memberships-pro/js/pmpro-checkout.js is responsible for incorrectly adding the required field asterisks to the fields which are no longer required:
Isolating the problem (mark completed items with an [x]):
WordPress Environment
Wordpress 6.6.2
PHP 8.0
PMPro 3.2.2
The text was updated successfully, but these errors were encountered: