BuddyPressで、マイページのナビで、他人のアクティビティを見えなくする方法

<結論>

/wp-content/plugins/buddypress/bp-activity/classes/class-bp-activity-component.php

$main_navに以下のように追加。

 

 

$main_nav = array(

'name' => _x( 'Activity', 'Profile activity screen nav', 'buddypress' ), 
'slug' => $slug,
'position' => 10,
'screen_function' => 'bp_activity_screen_my_activity',
'default_subnav_slug' => 'just-me',
'item_css_id' => $this->id,
'show_for_displayed_user' => '' /*自分にしか見れないようにするにはこれを追加する*/
);

 

<以下、思考過程の忘備録>

bp_get_displayed_user_nav()でナビ部を作成

foreach ( $bp->members->nav->get_primary() as $user_nav_item ) {で作成

プロパティ:show_for_displayed_userで、表示/非表示を決定

'show_for_displayed_user' => $r['show_for_displayed_user'],

$r = wp_parse_args( $args, $defaults );

//wp_parse_args は、引数の配列とデフォルト値の配列を結合するための汎用の関数です。

($rの一例)

Array ( [name] => プロフィール
[slug] => profile
[item_css_id] => xprofile
[show_for_displayed_user] => 1
[site_admin_only] =>
[position] => 20
[screen_function] => xprofile_screen_display_profile
[default_subnav_slug] => public )

Array ( [name] => トップ
[slug] => activity
[item_css_id] => activity
[show_for_displayed_user] => 1
[site_admin_only] =>
[position] => 10
[screen_function] => bp_activity_screen_my_activity
[default_subnav_slug] => just-me )

Array ( [name] => 友達 0
[slug] => friends
[item_css_id] => friends
[show_for_displayed_user] => 1
[site_admin_only] =>
[position] => 60
[screen_function] => friends_screen_my_friends
[default_subnav_slug] => my-friends )

Array ( [name] => グループ 1
[slug] => groups
[item_css_id] => groups
[show_for_displayed_user] => 1
[site_admin_only] =>
[position] => 70
[screen_function] => groups_screen_my_groups
[default_subnav_slug] => my-groups )

Array ( [name] => メッセージ
[slug] => messages
[item_css_id] => messages
[show_for_displayed_user] =>
[site_admin_only] =>
[position] => 50
[screen_function] => messages_screen_inbox
[default_subnav_slug] => inbox )

Array ( [name] => 通知
[slug] => notifications
[item_css_id] => notifications
[show_for_displayed_user] =>
[site_admin_only] =>
[position] => 30
[screen_function] => bp_notifications_screen_unread
[default_subnav_slug] => unread )

Array ( [name] => 設定
[slug] => settings
[item_css_id] =>
[show_for_displayed_user] =>
[site_admin_only] =>
[position] => 100
[screen_function] => bp_settings_screen_general
[default_subnav_slug] => general )

Array ( [name] => フォーラム
[slug] => forums
[item_css_id] => forums
[show_for_displayed_user] => 1
[site_admin_only] =>
[position] => 80
[screen_function] => bbp_member_forums_screen_topics
[default_subnav_slug] => topics )