How To Add Hacks In Your BuddyPress Site Without Loosing Them In The Next Update ?

Add actions and hacks without touching your theme’s function.php file. So that you don’t loose them anytime while running BuddyPress update.

No need of editing your theme’s function file and keeping a record of your edits so that in the next update you can easily put it at the right place.

Have you heard about bp-custom.php anywhere. This doesn’t exist by default in BuddyPress but you may create it anytime in your wordpress/wp-content/ directory for adding your codes and hacks for BuddyPress. bp-custom.php is often compared to your theme’s functions.php file but it has  two main differences:

  1. Your bp-custom.php runs from the /wp-content/plugins/ directory. Hence it becomes independent from your theme and useful for adding BuddyPress-specific code snippets. Code written here always loads regardless of what theme you are using.
  2. Your bp-custom.php runs early in the BuddyPress-loading process. Hence you can easily override various BuddyPress settings.

How To Create BuddyPress Custom File ?

You have to create this file in your WordPress site’s plugin folder, this would be its address /wp-content/plugins/bp-custom.php

Create a blank file and add the following code:

<?php
// hacks and mods will go here
?>

Now save/upload this file as bp-custom.php in your site’s plugin folder. Verify its address with /wp-content/plugins/bp-custom.php

Now you can add all those actions here itself which you were adding in your theme’s function.php file before.

For example:

You can add the BuddyPress hack for removing profile links that automatically appears in member’s profile:

Add following hack in this (bp-custom.php) file:

function remove_xprofile_links() {
remove_filter( ‘bp_get_the_profile_field_value’, ‘xprofile_filter_link_profile_data’, 50, 2 );
}
add_action( ‘plugins_loaded’, ‘remove_xprofile_links’ );

Now no need to edit your theme’s function file and hesitate while running BuddyPress update. Your BuddyPress hacks are safe in your bp-custom.php file.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.