Bug: Value attribute doesn't work when registering a field
Opened this issue · 1 comments
JarrydLong commented
Describe the bug
When registering a field and setting the value for that field, this is no longer getting carried through and doesn't show in the field.
To Reproduce
Steps to reproduce the behavior:
- Use this recipe:
function hide_from_directory_by_default_example() {
// don't break if Register Helper is not loaded
if ( ! function_exists( 'pmprorh_add_registration_field' ) || is_admin() ) {
return false;
}
// define the fields
$fields = array();
$fields[] = new PMProRH_Field(
'pmpromd_hide_directory',
'hidden',
array(
'showmainlabel' => false,
// 'profile' => 'admin',
'value' => '1',
)
);
foreach ( $fields as $field ) {
pmprorh_add_registration_field(
'checkout_boxes', // location on checkout page
$field // PMProRH_Field object
);
}
// that's it. see the PMPro Register Helper readme for more information and examples.
}
add_action( 'init', 'hide_from_directory_by_default_example' );
- View page source. Search for pmpromd_hide_directory. The value will be empty. It should have a value of 1
Expected behavior
A value of 1 should be available in that field
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.
WordPress Environment
WP 5.5.1
PMPro 2.4.4
Register Helper 1.7
JarrydLong commented
Further testing has found that this works when you're a visitor. Doesn't work when you're logged in.
Reference to where the logic for this happens:
pmpro-register-helper/classes/class.field.php
Lines 883 to 892 in e90c450