[buddypress-trac] [BuddyPress Trac] #7304: xProfile Group field
buddypress-trac
noreply at wordpress.org
Tue Oct 25 16:16:53 UTC 2016
#7304: xProfile Group field
-------------------------------+------------------
Reporter: danbp | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone:
Component: Extended Profile | Version: 2.7
Severity: normal | Resolution:
Keywords: reporter-feedback |
-------------------------------+------------------
Comment (by dcavins):
Hi @danbp: I was testing your snippet, too, and it works to hide groups
from the "view" screen of the profile (if you remove the
`bp_is_user_profile_edit()` conditional), but has no effect on the edit
view.
As @boonebgorges says above, to prevent the profile group "tab" link from
being created, the logic chain starts with `bp_profile_group_tabs()` in
`members/edit.php` which leads me to `bp_get_profile_group_tabs()`, where
the groups are fetched via `bp_profile_get_field_groups()`. I can exclude
tabs using the following code:
{{{
function bpfr_hide_profile_field_group( $groups ) {
// Hide the profile group tabs on the edit interface for all non-
admins.
if ( bp_is_user_profile_edit() && ! current_user_can( 'bp_moderate' )
) {
$remove_groups = array( 2 ); // Put the IDs of the groups to
remove here, separated by commas.
foreach ( $groups as $key => $group_obj ) {
if ( in_array( $group_obj->id, $remove_groups ) ) {
unset( $groups[$key] );
}
}
}
return $groups;
}
add_filter( 'bp_profile_get_field_groups', 'bpfr_hide_profile_field_group'
);
}}}
Note that this won't prevent users from actually editing those groups--
they can still access the edit group url directly, and the default
template will allow access.
Your code *does* work for excluding fields on the edit form, though. So
maybe that's a source of confusion.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7304#comment:5>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list