Advertisement
vapvarun

Change default landing tab for BuddyPress Activity directory

Apr 19th, 2022
1,625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. /**
  2.  * Set default activity directory tab for BuddyPress
  3.  */
  4. function reign_set_default_activity_directory_tab() {
  5.     // If user is not logged in or
  6.     // If the scope is already set, do not do anything ok.
  7.     if ( ! is_user_logged_in() || isset( $_COOKIE['bp-activity-scope'] ) ) {
  8.         return ;
  9.     }
  10.     // additional check for activity dir
  11.     if ( ! bp_is_activity_directory() ) {
  12.         return ;
  13.     }
  14.     $tab = 'groups'; // 'all', 'friends', 'groups', 'mentions'
  15.     // Set scope to our needed tab,
  16.     // In this case, I am setting to the 'friends' tab
  17.     setcookie( 'bp-activity-scope', $tab,null, '/' );
  18.     $_COOKIE['bp-activity-scope'] = $tab;
  19. }
  20. add_action( 'bp_template_redirect', 'reign_set_default_activity_directory_tab' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement