Changing the default behaviour of BuddyPress
BuddyPress Default Behaviour
There are a lot of things that happen by default in BuddyPress that you may have a need to change. For example the types of activities displayed in the activity pages, how many activity items are displayed per page etc. These things can be changed, but you will need to have some knowledge of coding, or be applying a code snippet that you’ve been given.
Part of the problem with modifying a template is that if you simply go to the Plugins directory and edit the plugin in-situ then the files will be over-written on a plugin update and your changes will be lost.
This is where the BuddyPress Template overload comes in. With the BuddyPress Template Overload a standard set of default files can be modified without the risk of losing them after an update.
This does mean that there is an added burden on you to keep an eye on the default template files and if they change then you will need to update them with your code and reapply then into your overload directories.
The BuddyPress Codex Page related to template overloads is here. I strongly recommend you review this page and get to know the BuddyPress Codex, it is filled with relevant information for affecting the operation of the various files you will be editing.
Create a BuddyPress Template Overload
This involves copying a set of default configuration files from the bp-legacy directory of your BuddyPress plugin (
/wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/...) to a place where you can modify them without risk of them being over-written during a plugin update (They will move to
/wp-content/themes/yourchildtheme/buddypress/...). Once you have created these files, you will be able to modify them and their settings will take precedence over any default settings set elsewhere.
The task involves copying the directory structure that is beyond bp-legacy onto your local hard disk, where you will edit them, and then copy the edited files into the same structure to your
/wp-content/themes/yourchildtheme/buddypress directory in your WordPress install, at which point they will become your master configuration files for the overloaded BuddyPress components.
BP Template Overloader
One of the issues with creating a template overload as described above is that if you change your theme then you will have to manually copy the overload files over to the new theme. This can become cumbersome and an alternative to this has ben created with BP Template Overloader. This provides for a Theme Independent Overload as well as a graphical interface for managing overload files.
Determine which files you need to change to affect the changes you want
This is largely a case of working through the codex, and also looking at the structure and content of the overload files, some of the significant directories are as follows:
Details of key parts of BuddyPress
The Members Loop creates the content for the Members directory page, Detailed information about the Members Loop can be found in the BuddyPress Codex – Members Loop.
There’s a nice tutorial on customising the members directory here.
The Groups Loop creates the content for the Groups directory page. Detailed information about the Groups Loop can be found in the BuddyPress Codex – Groups Loop.
The Activity Loop creates the content for the Activity page. Detailed information about the Activity Loop can be found in the BuddyPress Codex – Activity Loop.
Group Members Loop
The Group Members Loop creates the group members list. Detailed information about the Group Members Loop can be found in the BuddyPress Codex – Group Members Loop.
Details of BuddyPress hooks can be found at Hookr.io
Useful BuddyPress code Snippet Tutorials
There are some great tutorials over on the BuddyPress Codex, if you are getting into the idea of seriously modifying your installation they are well worth a look:
Tutorial on displaying Xprofile fields in the members Profile.
Tutorial on adding “Add to Group” bulk action in Dashboard>>Users>>All Users.
Tutorial on adding a new link to the BuddyPress drop down menu.
Tutorial on Changing the “Activity” components name and slug to something else
Tutorial on Adding a custom tab to the groups page.
Tutorial on adding a Custom Email that sends a notification to a post author of comments on their post.
Tutorial on Group Types.