Skip to content

PROD-10260 - Fix: Cannot find Group meta boxes (WP Fusion) - #5041

Open
sajib-bb wants to merge 1 commit into
releasefrom
PROD-10260
Open

PROD-10260 - Fix: Cannot find Group meta boxes (WP Fusion)#5041
sajib-bb wants to merge 1 commit into
releasefrom
PROD-10260

Conversation

@sajib-bb

Copy link
Copy Markdown

Jira Issue:

https://buddyboss.atlassian.net/browse/PROD-10260

General Note

Keep all conversations related to this PR in the associated Jira issue(s). Do NOT add comment on this PR or edit this PR’s description.

Notes to Developer

  • Ensure the IDs (i.e. PROD-1) of all associated Jira issues are reference in this PR’s title
  • Ensure that you have achieved the Definition of Done before submitting for review
  • When this PR is ready for review, move the associate Jira issue(s) to “Needs Review” (or “Code Review” for Dev Tasks)

Notes to Reviewer

  • Ensure that the Definition of Done have been achieved before approving a PR
  • When this PR is approved, move the associated Jira issue(s) to “Needs QA” (or “Approved” for Dev Tasks)

@sajib-bb sajib-bb changed the title Added support of WP Fusion Group meta boxes PROD-10260 - Fix: Cannot find Group meta boxes (WP Fusion) Aug 23, 2026
@sajib-bb
sajib-bb requested a review from reza-bb August 23, 2026 08:44
@sajib-bb sajib-bb self-assigned this Aug 23, 2026

@reza-bb reza-bb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please check the feedback and update accordingly.

$group_id = is_object( $group ) && isset( $group->id ) ? (int) $group->id : 0;
return bb_legacy_wpf_group_tag_extra_data( bb_legacy_wpf_group_settings( $group_id )['apply_tags'] );
},
'save_value' => function ( $group, $value ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Removing the last chip makes AjaxMultiSelectField emit [], appendToFormData() in utils/ajax.js appends nothing for an empty array, so registered_field_wpf_group_* is absent from $_POST and save_fields_data() skips this field entirely (if ( ! isset( $_POST[ $post_key ] ) ) { continue; }).
Net effect: these three fields are add/replace-only — "Link with Tag" can never be unset, and the value reappears on reopen. Removing one of two tags works; going to zero does not.
Smallest fix is in GroupEditModal.js:333 — send '' when the value is an empty array. bb_legacy_wpf_sanitize_group_tag_ids( '' ) already returns array(), so no PHP change needed.

Same for line #621 & #651

return;
}

groups_update_groupmeta( $group_id, 'wpf-settings-buddypress', $settings );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

direct meta write bypasses WP Fusion's own group save

compat/bp-auto-group-join.php replays the legacy side-effect on bb_admin_after_save_group precisely because the plugin's own nonce path never runs in Settings 2.0. This writes groupmeta directly and never populates $_POST['wpf-settings-buddypress'], while class-bb-admin-groups-ajax.php:1475 still fires bp_group_admin_edit_after.
Two risks: any member/tag reconciliation inside WPF_BuddyPress::save_groups_data() no longer fires, and if that handler writes/deletes the meta key unconditionally it could clobber what we just saved.
Can't verify WP Fusion's source from this repo — please confirm the hook and body, and replay the array into $_POST (or call the sync explicitly) if there are side-effects.

return;
}

if ( ! function_exists( 'groups_get_groupmeta' ) ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No guard that WP Fusion's BuddyPress integration is loaded

$out = array_values( array_unique( $out ) );

if ( null !== $max && $max > 0 && count( $out ) > $max ) {
$out = array_slice( $out, -$max );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

silent truncation on the single-tag fields

if ( ! is_scalar( $value ) ) {
continue;
}
$value = trim( (string) sanitize_text_field( $value ) );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sanitize_text_field() can mutate add_tags-CRM tag ids


$stored = groups_get_groupmeta( $group_id, 'wpf-settings-buddypress' );

return is_array( $stored ) ? array_merge( $defaults, $stored ) : $defaults;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

array_merge( $defaults, $stored ) guarantees the three keys exist but preserves whatever type is stored. If a leaf were ever a scalar, get_value returns a string, Array.isArray() fails and the saved tag renders as no chip.
It does self-heal on the next save, so this is hardening rather than a bug.
A (array) cast on each leaf in the return would close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants