BuddyDev

Search

bp-custom.php is a php file that is loaded before BuddyPress loads anything else. In other words, The BuddyPress plugins looks for the presence of bp-custom.php in the plugins directory and  if it is present, It is loaded. After that, BuddyPress continues loading the core components. If you don’t have this file in your wp-content/plugins directory, please create a file named bp-custom.php there to add the custom codes.

Here is a flow chart to show the process, when and how it is loaded.

 

FAQ:-

Is it a required file?

No. It is optional.

What is the benefit of keeping code in bp-custom.php instead of theme’s functions.php?

Good question.  Your changes will be gone when you change the theme but the code in bp-custom.php will always be there. It is not dependent on a theme. So, use it to keep common codes.

Do I need to create it?

Yes, if it is not present in your wp-content/plugins directory.

What is the purpose of it?

The actual purpose was to allow you run your code before BuddyPress runs, It can be used to hook into various BuddyPress features.

Can you provide a starter file?

Sure. You may use this from here

https://gist.github.com/sbrajesh/55639df69806b564a9765562a4f40e37