#5650 closed defect (bug) (duplicate)
bp_after_has_profile_parse_args not working correctly
Reported by: | danbp | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Extended Profile | Keywords: | |
Cc: |
Description
I'm trying to hide some profile groups to not logged in visitors by using the new bp_after_$filter_key_parse_args, http://codex.buddypress.org/plugindev/using-bp_parse_args-to-filter-buddypress-template-loops/#filtering-bp_parse_args/
When i use this function
function bpfr_make_profile_tab_members_only( $retval ) { if( !is_user_logged_in() ) { $retval['exclude_groups'] = '1,3'; } return $retval; } add_filter( 'bp_after_has_profile_parse_args', 'bpfr_make_profile_tab_members_only' );
In the best case, ID 1 is always showing and the fields who shoud stay don't come up. Very strange.
I have a total of 5 profile groups. I played around with the if statement and also with the profile group ID's. Nothing is going correctly and varies strangely, depending of the if/if! or the ID's.
Aside, i have also a warning Missing argument 2. Changed it, but had no influence on the function.
See https://buddypress.trac.wordpress.org/ticket/5649
Change History (4)
#2
@
10 years ago
Solved !
The error was in bp-xprofile-classes.php:156
Changed the line to
$where_sql = $wpdb->prepare( "WHERE g.id NOT IN ({$exclude_groups})", $profile_group_id );
(but a php notice about wpdb::prepare) see #5649
#3
@
10 years ago
- Component changed from Members to XProfile
- Milestone 2.0.1 deleted
- Resolution set to duplicate
- Status changed from new to closed
danbp
I have an advice. The group of profile field with ID 1 is the base profile and contains the primary field. I think i'd play with the field visibility in that group of profile field to eventually hide some fields but would always have the base profile group show.
It seems to be a side effect of #5649 so i will close as duplicate. Feel free to reopen this ticket if i did wrong.
#4
@
9 years ago
If this isn't relevant I'm sorry. I found exclude_fields and exclude_groups didn't work for my instance as a plugin was using a higher priority on the bp_after_has_profile_parse_args filter hook which overwrote my values.
To resolve I made my call higher and then did a check and if the fields weren't empty I appended rather than just set them.
Cheers
Continuing my tests, the function is working correctly on a multisite config but not on a single install.
exclude any group except id 1
On another hand, i can use
without problems.