Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions includes/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -1341,12 +1341,13 @@ function pmpro_get_field_html( $field = null ) {
$field_name = $field->name;
$field_type = $field->type;
$field_required = $field->required;
$field_readonly = $field->readonly;
$field_profile = $field->profile;
$field_readonly = $field->readonly;
$field_profile = $field->profile;
$field_wrapper_class = $field->wrapper_class;
$field_element_class = $field->element_class;
$field_hint = $field->hint;
$field_options = $field->options;
$field_buddypress = $field->buddypress;
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing $field->buddypress directly without checking if the property exists could cause a PHP notice for fields saved before this feature was added. For backward compatibility, consider using the null coalescing operator or isset check, such as $field_buddypress = $field->buddypress ?? ''; to safely handle fields that don't have this property.

Suggested change
$field_buddypress = $field->buddypress;
$field_buddypress = $field->buddypress ?? '';

Copilot uses AI. Check for mistakes.
} else {
// Default field values
$field_label = '';
Expand All @@ -1359,6 +1360,7 @@ function pmpro_get_field_html( $field = null ) {
$field_element_class = '';
$field_hint = '';
$field_options = '';
$field_buddypress = '';
}

// Other vars
Expand Down Expand Up @@ -1481,6 +1483,15 @@ function pmpro_get_field_html( $field = null ) {
</div> <!-- end pmpro_userfield-field-setting -->
</div> <!-- end pmpro_userfield-field-setting-dual -->

<?php if(defined('PMPROBP_DIR')) : ?>
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional check should have a space after if and before the opening parenthesis to follow WordPress coding standards. It should be if ( defined( 'PMPROBP_DIR' ) ) instead of if(defined('PMPROBP_DIR')).

Suggested change
<?php if(defined('PMPROBP_DIR')) : ?>
<?php if ( defined( 'PMPROBP_DIR' ) ) : ?>

Copilot uses AI. Check for mistakes.
<div class="pmpro_userfield-field-setting">
<label>
<?php esc_html_e( 'BP XField Name', 'paid-memberships-pro' ); ?><br />
<input type="text" placeholder="The Name of the Xprofile Field, or blank to not sync" name="pmpro_userfields_field_buddypress" value="<?php echo esc_attr( $field_buddypress );?>" />
</label>
</div> <!-- end pmpro_userfield-field-setting -->
<?php endif; ?>
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closing PHP tag should be on the same indentation level as the opening <?php tag. This line should have 3 fewer spaces of indentation to align properly with line 1486.

Suggested change
<?php endif; ?>
<?php endif; ?>

Copilot uses AI. Check for mistakes.

<div class="pmpro_userfield-field-setting">
<label>
<?php esc_html_e( 'Hint (optional)', 'paid-memberships-pro' ); ?><br />
Expand Down Expand Up @@ -1615,6 +1626,7 @@ function pmpro_load_user_fields_from_settings() {
'options' => $options,
'levels' => $levels,
'memberslistcsv' => true,
'buddypress' => $settings_field->buddypress,
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing $settings_field->buddypress directly without checking if the property exists could cause a PHP notice for fields saved before this feature was added. For backward compatibility, consider using the null coalescing operator or isset check, such as $settings_field->buddypress ?? '' to safely handle fields that don't have this property.

Suggested change
'buddypress' => $settings_field->buddypress,
'buddypress' => $settings_field->buddypress ?? '',

Copilot uses AI. Check for mistakes.
)
);
pmpro_add_user_field( $group->name, $field );
Expand Down
2 changes: 2 additions & 0 deletions js/pmpro-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ function pmpro_userfields_prep_click_events() {
let field_element_class = jQuery(this).find('input[name=pmpro_userfields_field_divclass]').val();
let field_hint = jQuery(this).find('textarea[name=pmpro_userfields_field_hint]').val();
let field_options = jQuery(this).find('textarea[name=pmpro_userfields_field_options]').val();
let field_buddypress = jQuery(this).find('input[name=pmpro_userfields_field_buddypress]').val() || "";

// Get level ids.
let field_levels = [];
Expand All @@ -517,6 +518,7 @@ function pmpro_userfields_prep_click_events() {
'element_class': field_element_class,
'hint': field_hint,
'options': field_options,
'buddypress': field_buddypress,
}

// Add to array. (Only if it has a label or name.)
Expand Down