Hi Ravi, here you go:
/** ANONYMOUS GROUP FUNCTIONALITY*/ /** * 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 ); } ); /** * 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( 2 );// 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 );
Hi Nic,
I will be assisting you within next 2 days and help you resolve it.Thank you for the patience.
Regards
BrajeshHi Brajesh
Is there any word on this? I would just like for the anonymity to work in selected groups, but for it to be optional in those selected groups.
Many thanks
NicolaHi Nicola,
I am sorry, You have waited too long on this.Please remove any custom code you used earlier and put this in your bp-custom.php
/** * Filter is anonymous activity should be allowd. * * @param bool $is is enabled. * * @return bool */ function bp_custom_anonymous_is_enabled_for_group( $is ) { if ( ! bp_is_group() ) { return $is; } $enabled_groups = array( 'alpha-beta', 'abs', 'group-slug-3' );//group slugs $group = groups_get_current_group(); if ( in_array( $group->slug, $enabled_groups ) ) { $is = true; } else { $is = false; } return $is; } add_filter( 'bp_anonymous_is_valid_screen', 'bp_custom_anonymous_is_enabled_for_group' );
Please make sure to change the slug with appropriate once and It will work.
Regards
BrajeshYou are welcome 🙂
I am glad it is working.Regards
Brajesh
You must be logged in to reply to this topic.
This topic is: resolved