PROD-10260 - Fix: Cannot find Group meta boxes (WP Fusion) - #5041
PROD-10260 - Fix: Cannot find Group meta boxes (WP Fusion)#5041sajib-bb wants to merge 1 commit into
Conversation
reza-bb
left a comment
There was a problem hiding this comment.
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 ) { |
There was a problem hiding this comment.
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.
| return; | ||
| } | ||
|
|
||
| groups_update_groupmeta( $group_id, 'wpf-settings-buddypress', $settings ); |
There was a problem hiding this comment.
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' ) ) { |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
silent truncation on the single-tag fields
| if ( ! is_scalar( $value ) ) { | ||
| continue; | ||
| } | ||
| $value = trim( (string) sanitize_text_field( $value ) ); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
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
Notes to Reviewer