Hide friendshp in sitewide activity stream
-
Hi,
As some users may not want other members to see who they have just made new friends for privacy reason, is there any way to hide this activity stream from the the sitewide activity stream?
Thanks a lot!
-
here a complete solution you can use for friends privacy.
– Whe’re going to show the friends menu only to… friends !
– We remove friends activity.Copy this to bp-custom.php
function bpfr_maybe_hide_friends_nav_etc() { $retval = false; if ( bp_is_user() && ! bp_is_my_profile() && ! friends_check_friendship( bp_displayed_user_id(), bp_loggedin_user_id() ) ) { $retval = true; } return $retval; } function bpfr_hide_friends_nav_to_non_friends() { // Stop if condition is not filed if ( ! bpfr_maybe_hide_friends_nav_etc() ) { return; } // otherwise, we remove the nav bp_core_remove_nav_item( 'friends' ); // bp topnav bp_core_remove_subnav_item( 'activity', 'friends' ); //bp subnav (my activities, my groups, etc) } add_action( 'bp_ready', 'bpfr_hide_friends_nav_to_non_friends' ); // we want also to remove all friends related activities to non friends function bpfr_hide_friends_activity_type_to_non_friends( $activity_action = array(), $component_id = '' ) { // if condition is not filed we go back to original output if ( 'friends' != $component_id || ! bpfr_maybe_hide_friends_nav_etc() ) { return $activity_action; } // otherwise, we remove member from context $activity_action['context'] = array_diff( $activity_action['context'], array( 'member' ) ); return $activity_action; } add_filter( 'bp_activity_set_action', 'bpfr_hide_friends_activity_type_to_non_friends', 10, 2 );
Related topic (other solution, or strict answer to your question) 😉
https://buddypress.org/support/topic/documentation-for-remove_action-activity-streams/#post-242974Hi,
Thanks! I upload the bp-custom.php to /wp-content/plugins/ and it causes my site completely blank. Please kindly help.
Have you read the codex about bp-custom ?
Do you omitted some opening or closing php tag ? Or have you a blank line at the end of the file ?Yes, I have read codex abot bp-custom. I also have added php tag as below.
<?php // hide friendship activity stream sitewide function bpfr_maybe_hide_friends_nav_etc() { $retval = false; if ( bp_is_user() && ! bp_is_my_profile() && ! friends_check_friendship( bp_displayed_user_id(), bp_loggedin_user_id() ) ) { $retval = true; } return $retval; } function bpfr_hide_friends_nav_to_non_friends() { // Stop if condition is not filed if ( ! bpfr_maybe_hide_friends_nav_etc() ) { return; } // otherwise, we remove the nav bp_core_remove_nav_item( 'friends' ); // bp topnav bp_core_remove_subnav_item( 'activity', 'friends' ); //bp subnav (my activities, my groups, etc) } add_action( 'bp_ready', 'bpfr_hide_friends_nav_to_non_friends' ); // we want also to remove all friends related activities to non friends function bpfr_hide_friends_activity_type_to_non_friends( $activity_action = array(), $component_id = '' ) { // if condition is not filed we go back to original output if ( 'friends' != $component_id || ! bpfr_maybe_hide_friends_nav_etc() ) { return $activity_action; } // otherwise, we remove member from context $activity_action['context'] = array_diff( $activity_action['context'], array( 'member' ) ); return $activity_action; } add_filter( 'bp_activity_set_action', 'bpfr_hide_friends_activity_type_to_non_friends', 10, 2 ); ?>
Please, use
<code>
button when you publish code on this forum.I tested the snippet and it works. No blank page or error message.
Do you use some other functions in bp-custom ?Check also the quotes. You should use straight quotes
'xxx'
, not apostrophe‘xxxx’
Oops! Sorry for this. I didn’t know this. Next time I will use button.
This is the first time I use bp-custom.php. There is no other codes/functions in this file. Could it be possibly caused by other plugins?
Could it be possibly caused by other plugins?
Yes, it’s possible, but i doubt it’s the case. To get sure, you can deactivate all plugins except BP and track down a culprit.
If the page or the whole site is blank after adding custom code, it’s generally due to missing tags or a php error.
Errors can also be generated by software who modify the file format. For example if you use the WP editor to add something to bp-custom, and you’re on the visual tab, you get weird results. Same thing if you edit bp-custom locally with Word or other such text-editor….
More about this here.
Weird! I use Notepad++ to create bp-custom.php and I add only the codes you provide, no other codes. I just tried again and it let my whole site become completely blank.
Or, is there any available plugin which can do the same thing? Thanks very much for your very kind help in this case!!!
No there is no plugin for this. Notepad is fine, but if copy/pasting a working code brings trouble, it would be better you find what is causing that issue.
Can you test with Twenty Thirteen ?
What about other plugins deactivated ?Also, activate wp_debug in wp-config.php and report the error message you get (if one).
- The topic ‘Hide friendshp in sitewide activity stream’ is closed to new replies.