Hi Brajesh
Is there any update on this? I’m hoping to go live with my site next week.
Thanks
NicolaHi Nic,
We have got this working. We will release it over the weekend and you may utilize this.Regards
BrajeshHI Nic,
Please upgrade to 1.0.9 and then, you can add the following code to your bp-custom.php/** * Disable UI. */ add_filter( 'bp_anonymous_is_valid_screen', function ( $valid ) { return false;// don't show ui. } ); /** * Custom enable for certain groups. * * @param bool $is is enabled. * @param string $context current context. * @param int $context_id context id. */ function bpanonymous_custom_enable( $is, $context, $context_id ) { if ( 'group' !== $context ) { return $is; } $allowed_groups = array( 1,2,3,4 );// please change with the group ids. return in_array( $context_id, $allowed_groups ); } add_filter( 'bp_anonymous_activity_is_anonymous_comment', 'bpanonymous_custom_enable', 10, 3 ); add_filter( 'bp_anonymous_activity_is_maybe_anonymous_comment', 'bpanonymous_custom_enable', 10, 3 ); add_filter( 'bp_anonymous_activity_is_anonymous_post', 'bpanonymous_custom_enable', 10, 3 );
Please make sure to change this
$allowed_groups = array( 1,2,3,4 );// please change with the group ids.
With correct group ids.
Any update/comment on these groups will be anonymous.
Regards
BrajeshHi
Sorry to bug you on this again 🙂 Could you tell me how to tweak the code again so that it’s only on the specific group but the UI is shown so that anonymity is optional? Feedback from users suggests this would be preferred.
Thanks!
NicHi Nic,
No problem.Our team will assist you on Monday/Tuesday with the customization.
Regards
BrajeshHello Nic,
To show the ui as optional. Please modify the above code
Replace the following code
/** * Disable UI. */ add_filter( 'bp_anonymous_is_valid_screen', function ( $valid ) { return false;// don't show ui. } );
with
/** * Disable UI. */ add_filter( 'bp_anonymous_is_valid_screen', function ( $valid ) { if ( ! bp_is_group() ) { return $valid; } // Do not show ui on anonymous groups. $anonymous_groups = array( 43, 42 );// please change with the group ids. return ! in_array( bp_get_current_group_id(), $anonymous_groups ); } );
Regards
RaviHi Ravi
I tested this and unfortunately it doesn’t seem to work. I notice your comment in the code says “// Do not show ui on anonymous groups.”
However I /do/ want to show it on the anonymous groups, but only those I have specified to be anonymous. At the moment, this code removes the UI from the anonymous groups and shows it on the groups where anonymity is not enabled.
Thanks
NicolaHello Nicola,
Sorry for the delayed reply please change the following line
return ! in_array( bp_get_current_group_id(), $anonymous_groups );
with
return in_array( bp_get_current_group_id(), $anonymous_groups );
it will show ui on selected groups. Let me know if works or not
Regards
RaviHi Ravi
Unfortunately this didn’t seem to work – it removed the UI everywhere, and made the specified group anonymous only again
Thanks
Nicola
You must be logged in to reply to this topic.