Set default landing tab for BuddyPress Activity directory

If you are interested in changing the default landing  tab( activity listing type ) for BuddyPress Activity directory, then you can do it easily. We are going to see it with an example where we will change the default landing tab from “All Members” activity to “My friends” activity.

All you need to do is put the following code in your bp-custom.php

Here is a screenshot of the default activity tab:-

And here is what the user sees when they visit the activity directory for the first time(after you use the previous code)

As you noticed, the default landing tab is set to “My friends ” and lists friends activity instead of the default “All members” activity.

Code Explanation:-

In the code we check if a user is logged in, the activity scope is not set and the current page is activity directory, then we set ‘friends’ as the default scope. It makes BuddyPress display friends activity on the default activity directory landing page instead of the All members activity. You can change the scope to any valid activity scope. The other available scopes are “groups” and “mentions”.

Please do note that the default scope is only set if it was not already set earlier. If you are testing the code and you had visited activity directory earlier and had clicked on one of the tabs, your activity-scope would be already set. The code will only work for you when you clear the cookies.

Have fun working with BuddyPress 🙂


4 Responses to Set default landing tab for BuddyPress Activity directory

Leave a Reply

Are you looking for support?

Please ask support questions in BuddyDev Forum and help us serve you better. Please use comment for general discussion/feature suggestions.

Your email address will not be published. All the fields marked as * are required.

If you are posting code, please use <pre> { Your Code Block } </pre>. Example:- <pre> echo $name; </pre>

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">