{"id":26,"date":"2013-10-01T08:48:47","date_gmt":"2013-10-01T08:48:47","guid":{"rendered":"http:\/\/buddydev.com\/docs\/?p=26"},"modified":"2019-08-30T07:49:03","modified_gmt":"2019-08-30T07:49:03","slug":"what-is-bp-custom-php","status":"publish","type":"post","link":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/","title":{"rendered":"What is bp-custom.php?"},"content":{"rendered":"<p><strong>bp-custom.php<\/strong> is a php file that is loaded before BuddyPress loads anything else. In other words, The <strong>BuddyPress plugins looks for the presence of bp-custom.php in the plugins directory<\/strong> and \u00a0if it is present, It is loaded. After that, BuddyPress continues loading the core components. If you don&#8217;t have this file in your wp-content\/plugins directory, please create a file named bp-custom.php there to add the custom codes.<\/p>\n<p>Here is a flow chart to show the process, when and how it is loaded.<\/p>\n<p><a href=\"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-27\" title=\"bp-custom-loading-order\" src=\"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png\" alt=\"\" width=\"716\" height=\"640\" srcset=\"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png 716w, https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order-300x268.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>FAQ:-<\/h3>\n<p><strong>Is it a required file?<\/strong><\/p>\n<p>No. It is optional.<\/p>\n<p><strong>What is the benefit of keeping code in bp-custom.php instead of theme&#8217;s functions.php?<\/strong><\/p>\n<p>Good question. \u00a0Your 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.<\/p>\n<p><strong>Do I need to create it?<\/strong><\/p>\n<p>Yes, if it is not present in your wp-content\/plugins directory.<\/p>\n<p><strong>What is the purpose of it?<\/strong><\/p>\n<p>The actual purpose was to allow you run your code before BuddyPress runs, It can be used to hook into various BuddyPress features.<\/p>\n<p><strong>Can you provide a starter file?<\/strong><\/p>\n<p>Sure. You may use this from here<\/p>\n<p><a href=\"https:\/\/gist.github.com\/sbrajesh\/55639df69806b564a9765562a4f40e37\">https:\/\/gist.github.com\/sbrajesh\/55639df69806b564a9765562a4f40e37<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 \u00a0if it is present, It is loaded. After that, BuddyPress continues loading the core components. If you don&#8217;t have this file in your wp-content\/plugins directory, &#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5687],"tags":[],"class_list":["clearfix","post-26","post","type-post","status-publish","format-standard","hentry","category-buddypress-guides"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is bp-custom.php? &#8226; BuddyDev Help Center<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is bp-custom.php? &#8226; BuddyDev Help Center\" \/>\n<meta property=\"og:description\" content=\"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 \u00a0if it is present, It is loaded. After that, BuddyPress continues loading the core components. If you don&#8217;t have this file in your wp-content\/plugins directory, ...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/\" \/>\n<meta property=\"og:site_name\" content=\"BuddyDev Help Center\" \/>\n<meta property=\"article:published_time\" content=\"2013-10-01T08:48:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-08-30T07:49:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png\" \/>\n<meta name=\"author\" content=\"Brajesh Singh\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brajesh Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/\",\"url\":\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/\",\"name\":\"What is bp-custom.php? &#8226; BuddyDev Help Center\",\"isPartOf\":{\"@id\":\"https:\/\/buddydev.com\/docs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png\",\"datePublished\":\"2013-10-01T08:48:47+00:00\",\"dateModified\":\"2019-08-30T07:49:03+00:00\",\"author\":{\"@id\":\"https:\/\/buddydev.com\/docs\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb\"},\"breadcrumb\":{\"@id\":\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#primaryimage\",\"url\":\"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png\",\"contentUrl\":\"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png\",\"width\":\"716\",\"height\":\"640\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/buddydev.com\/docs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is bp-custom.php?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/buddydev.com\/docs\/#website\",\"url\":\"https:\/\/buddydev.com\/docs\/\",\"name\":\"BuddyDev Help Center\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/buddydev.com\/docs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/buddydev.com\/docs\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb\",\"name\":\"Brajesh Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/buddydev.com\/docs\/#\/schema\/person\/image\/\",\"url\":\"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon\",\"contentUrl\":\"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon\",\"caption\":\"Brajesh Singh\"},\"sameAs\":[\"http:\/\/buddydev.com\/members\/sbrajesh\/\",\"https:\/\/x.com\/sbrajesh\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is bp-custom.php? &#8226; BuddyDev Help Center","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/","og_locale":"en_US","og_type":"article","og_title":"What is bp-custom.php? &#8226; BuddyDev Help Center","og_description":"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 \u00a0if it is present, It is loaded. After that, BuddyPress continues loading the core components. If you don&#8217;t have this file in your wp-content\/plugins directory, ...","og_url":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/","og_site_name":"BuddyDev Help Center","article_published_time":"2013-10-01T08:48:47+00:00","article_modified_time":"2019-08-30T07:49:03+00:00","og_image":[{"url":"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png","type":"","width":"","height":""}],"author":"Brajesh Singh","twitter_misc":{"Written by":"Brajesh Singh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/","url":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/","name":"What is bp-custom.php? &#8226; BuddyDev Help Center","isPartOf":{"@id":"https:\/\/buddydev.com\/docs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#primaryimage"},"image":{"@id":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#primaryimage"},"thumbnailUrl":"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png","datePublished":"2013-10-01T08:48:47+00:00","dateModified":"2019-08-30T07:49:03+00:00","author":{"@id":"https:\/\/buddydev.com\/docs\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb"},"breadcrumb":{"@id":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#primaryimage","url":"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png","contentUrl":"https:\/\/buddydev.com\/docs\/files\/2013\/10\/bp-custom-loading-order.png","width":"716","height":"640"},{"@type":"BreadcrumbList","@id":"https:\/\/buddydev.com\/docs\/buddypress-guides\/what-is-bp-custom-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/buddydev.com\/docs\/"},{"@type":"ListItem","position":2,"name":"What is bp-custom.php?"}]},{"@type":"WebSite","@id":"https:\/\/buddydev.com\/docs\/#website","url":"https:\/\/buddydev.com\/docs\/","name":"BuddyDev Help Center","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/buddydev.com\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/buddydev.com\/docs\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb","name":"Brajesh Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buddydev.com\/docs\/#\/schema\/person\/image\/","url":"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon","contentUrl":"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon","caption":"Brajesh Singh"},"sameAs":["http:\/\/buddydev.com\/members\/sbrajesh\/","https:\/\/x.com\/sbrajesh"]}]}},"_links":{"self":[{"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":11,"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":1717,"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/posts\/26\/revisions\/1717"}],"wp:attachment":[{"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buddydev.com\/docs\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}