Skip to content

pmpro-buddypress field sync support in GUI#3118

Open
DarkLotus wants to merge 2 commits intostrangerstudios:v3.2from
DarkLotus:bppmpropr
Open

pmpro-buddypress field sync support in GUI#3118
DarkLotus wants to merge 2 commits intostrangerstudios:v3.2from
DarkLotus:bppmpropr

Conversation

@DarkLotus
Copy link

@DarkLotus DarkLotus commented Aug 15, 2024

All Submissions:

Changes proposed in this Pull Request:

Brings across the abilty to enable Syncing PMPRO Fields to BP XProfile fields via the GUI instead of just via register helper code defined fields.
Adds a new input thats only visible in the user field settings if pmpro-buddypress is enabled, that lets you set the $field->buddypress value via GUI.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run tests with your changes locally?

Changelog entry

Add support for GUI user fields to support BP sync if pmpro-buddypress is installed.

@DarkLotus DarkLotus changed the title Bppmpropr pmpro-buddypress field sync support in GUI Aug 15, 2024
@andrewlimaza andrewlimaza requested a review from Copilot December 11, 2025 10:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds GUI support for syncing Paid Memberships Pro user fields to BuddyPress XProfile fields. Previously, this functionality was only available through register helper code-defined fields. The new feature is conditionally displayed in the user field settings when the pmpro-buddypress plugin is enabled.

Key Changes

  • Added buddypress property to user field objects to store the BuddyPress XProfile field name
  • Introduced a new GUI input field that allows admins to configure BP sync directly from the admin interface
  • Updated JavaScript to capture and save the buddypress field value when user fields are saved

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
js/pmpro-admin.js Added extraction of the buddypress field value from the form input and includes it in the field object when saving user field settings
includes/fields.php Added handling for the buddypress property throughout the field lifecycle: retrieval from field objects, display in the GUI (conditionally when PMPROBP_DIR is defined), and loading from settings into field instances

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<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.
$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.
'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.
</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.
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

Successfully merging this pull request may close these issues.

1 participant