Skip to:
Content
Pages
Categories
Search
Top
Bottom

Should I still use bp_custom.php in BP 1.1.x?

  • @peterverkooijen

    Participant

    Should I still use bp_custom.php in BP 1.1.2 and beyond? Or should I put all custom code in functions.php from now on? Is there a difference between the two?

Viewing 7 replies - 1 through 7 (of 7 total)
  • @mercime

    Participant

    Code in bp-custom.php is applied sitewide unless the function specifically targets certain blog/s much like if a MU-compat plugin is placed in mu-plugins folder. If you put the code in functions.php, , it would only affect only the blog using that specific theme. As of 1.2 bleeding, my bp-custom.php is still working sitewide.

    @johnjamesjacoby

    Keymaster

    bp-custom.php loads up before any BuddyPress components do, and functions.php loads after all plugins and WordPress core code does.

    So it isn’t a matter of “if,” it’s a matter of “why.”

    Basically…

    Use bp-custom.php to override core BuddyPress settings like slugs or constant values, or to load specific code BEFORE BuddyPress loads for whatever reason you might need to.

    Use functions.php if you need to add actions or filters to BuddyPress things. It’s good practice to make sure that actions and filters exist before attaching code to them. If you add a filter to a function that doesn’t exist yet, or you add it before/after the code is loaded/executed, then you’re ahead/behind the action/filter curve, so to speak.

    Different files for different purposes.

    @svenl77

    Participant

    In the codex:

    https://codex.buddypress.org/how-to-guides/modifying-the-buddypress-admin-bar/

    It says:

    Any custom code that we create can be placed in a file called bp-custom.php. It gets loaded with all the rest of bp automatically by bp during each page load. If you don’t have one already then create one in /wp-content/plugins/. So we’ll pretend that we have done just that and that our three new functions are going to be loaded with the rest of bp.

    but i needed to put the modified buddypress-admin-bar in the functions.php to work.

    Is there any reason?

    @rogercoathup

    Participant

    @sven. I had this problem in the past, because my mods in bp-custom.php were being overwritten when bp loaded itself.

    The details on how to get them to occur after bp has loaded, are in this thread:

    https://buddypress.org/forums/topic/remove-menu-from-admin-bar#post-22856

    or, as John points out above, they can go in functions.php which is called afterwards.

    @rogercoathup

    Participant

    A further thought (comments / corrections appreciated):

    If you make your modifications in bp-custom.php it will affect your entire BuddyPress installation (regardless of which theme you are using)

    If you make your modification in functions.php it will only affect the theme where you have made the changes. i.e. select a different theme and you will lose the changes.

    @arnonel

    Participant

    where do you put bp-custom.php or functions.php?

    everything i try with those gives me a blank page (ie, error)…

    stupid question, but you still have to put <?php and ?> in right?

    @designcloud

    Participant

    @arnonel

    bp-custom.php should go in wp-content/plugins

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Should I still use bp_custom.php in BP 1.1.x?’ is closed to new replies.
Skip to toolbar