I’m extending the client’s website to have social elements like public profile pages, profile activity, some custom-created content and such. Because I do like to build things myself, my first thought was to build all of this by myself from start. Not so great idea after thinking it thoroughly through.
I did look up some different options and landed to use BuddyPress as a core to provide all the usual profile things and such. It seems to work very well together with Restrict Content Pro which is a huge advantage. But oh well, I think you are not after the story about the site and plugins used.
BuddyPress has a lot of actions and filters to modify it, so it was a little surprise that there is no filter to disable status update functionality in user activity streams. That little text area where user can write their updates like it was a Facebook or something… The updates are then visible on users or in the selected group’s activity stream.
We didn’t want to have this feature, at least at this point, on the site so I needed to figure out a way to disable it. A little bit of search engine usage revealed proposed solutions to hide that area with CSS or to modify the BuddyPress template file. Needless to say, the CSS solution isn’t going to work as anyone with knowing how to use the browser inspector tool can just unhide it. Adding a new template file to the theme, modifying it and keeping up to date with BuddyPress changes sounded like too much trouble for achieving a small thing.
I was looking for a filter. I like filters. Those are handy, provide so many options to what to do with them. Most importantly you can gather a bunch of hooks, related to the same thing, into one file or plugin for an easier overall picture of what’s modified.
Quick view to BuddyPress code and there it was! The status update part is included by using
bp_get_template_part function and that function surely does have a filter. Let’s use that filter to short circuit the whole status update part and prevent the template part from ever being included.
Returning false, when BuddyPress tries to locate the template part essentially tells BuddyPress that there are no template part files available at all. That leads the user activity stream not to have the status update section. This solution works with both BuddyPress themes, legacy and Nouveau.
Hopefully, this little snippet can help someone else looking a neat solution to the same problem 🙂