Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Value attribute doesn't work when registering a field #199

Open
3 tasks done
JarrydLong opened this issue Oct 28, 2020 · 1 comment
Open
3 tasks done

Bug: Value attribute doesn't work when registering a field #199

JarrydLong opened this issue Oct 28, 2020 · 1 comment

Comments

@JarrydLong
Copy link
Contributor

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:

  1. 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' );
  1. View page source. Search for pmpromd_hide_directory. The value will be empty. It should have a value of 1

Screenshots
image

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
Copy link
Contributor Author

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:

} elseif ( ! empty( $current_user->ID ) ) {
$userdata = get_userdata( $current_user->ID );
if ( ! empty( $userdata->{$this->name} ) ) {
$value = $userdata->{$this->name};
} else {
$value = '';
}
}
elseif(!empty($this->value))
$value = $this->value;

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

No branches or pull requests

1 participant