Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom Templates not Loading after BP update 1.7.2 to 2.4


  • paddy33
    Participant

    @paddy33

    Hi. I recently inherited a site with a fair bit of BuddyPress customizations done from 2013. It’s running on BP 1.7 so the first step was to update to the latest version. But the custom templates (ie. ‘template-user-account.php’) are not showing up after the update.

    – Most of the custom template files are in the child theme’s root (untouched)
    – Already moved any other custom BP files from /bp-legacy/buddypress to /childtheme/buddypress

    I have 2 copies of the site installed locally with before (BP 1.7) and after (BP2.4) update versions to do a detailed comparison. The WhatTheFile plugin shows different files used to generate the same (User Dashboard) page:

    Original Site (BP 1.7.2): created from – ‘template-user-account.php’ file
    Updated Site (BP 2.4): created from – ‘page.php’ and ‘content-page.php’

    BP 1.7 introduced a new template loading procedure that mirrors WP’s Template Hierarchy. If the Original site is using BP 1.6, it may make sense how the update caused templates to be loaded differently, and hence produce the difference highlighted above.

    But since the Original site is already using 1.7.2, what could cause the Updated Site not to be able to load the correct ‘template-user-account.php’ file?

    My best guess so far is that this isn’t working after the update:

    function user_dashboard_template() {
    	bp_core_load_template( 'template-user-account' );
    }

    Thanks for any insights or suggestions.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Ooh. Hi @paddy33! Sounds like you’ve got yourself an interesting challenge. I’m very interested to keep in touch to learn about what it’s like to upgrade a site between these versions.

    My initial thoughts:

    1) template-user-account.php is not/has never been the name of a template part bundled with any version of BuddyPress, so we’re dealing with a custom theme integration, which will make things a bit trickier for us to help (since we can’t see its code).

    2) While the Original site might be BP 1.7.2, it doesn’t mean the templates were built with *that* version; it could have launched on 1.5 or 1.6, etc. In this case, it’s quite possible theme compatibility was explicitly disabled.

    Does this line appear anywhere in your codebase?

    add_theme_support( 'buddypress' );

    3) I think you’re going to have to debug (hopefully in a development environment or development server) bp_core_load_template and compare where its looking for a template vs. where the template actually is.


    paddy33
    Participant

    @paddy33

    After rolling back to 1.7 and gradually updating each version, it appears it’s the update to 2.1 that’s the issue, as the templates are still loading fine with BP 2.0.3

    Digging deeper, it seems that it’s the /plugins/buddypress/bp-core folder which causes the problem

    Couldn’t track down the cause looking for clues in the changelog https://codex.buddypress.org/releases/version-2-1/

    This line is a potential but i couldn’t understand the info from r8820 – “In bp_core_load_template(), only use locate_template for older bp-default themes (r8820)”


    r-a-y
    Keymaster

    @r-a-y

    @paddy33 – Try adding this line to your theme’s functions.php in your 'after_setup_theme' hook.

    add_theme_support( 'buddypress' );

    This should bring back support to use bp_core_load_template() in your theme. However, may I ask what URL you are attempting to load bp_core_load_template( 'template-user-account' ) on?

    If this is a non-BuddyPress page (eg. example.com/dashboard), just use get_template_part() instead of bp_core_load_template().


    paddy33
    Participant

    @paddy33

    Hi Paul @djpaul.

    #1 Yes, you’re right. If it’s a custom template that loads ok with BP 1.7.2 all the way up to 2.0.3, and only has an issue when updating to BP 2.1, is it safe to assume that it’s not anything in the custom template’s code that’s causing the problem? If not, i can dig into it and share anything that’ll help to solve this.

    #2 “it doesn’t mean the templates were built with *that* version” – do you think it’s a strong possibility the code in the custom template may be culprit? I just took a quick look and it seems to be quite standard.

    add_theme_support( ‘buddypress’ ) is only in these files:

    > wp-content\plugins\buddypress\bp-core\bp-core-theme-compatibility.php:
    > wp-content\plugins\buddypress\bp-themes\bp-default\functions.php:

    #3 “compare where its looking for a template vs. where the template actually is.” – The strange thing is that it works with BP 2.0.3 and only ‘breaks’ upon update to 2.1, and the template is sitting in the same place (child theme’s root) all the time. Appreciate any suggestions if you have them, as i’m out of ideas as a novice tinkerer.


    paddy33
    Participant

    @paddy33

    @djpaul @r-a-y Brilliant! I added theme support for BuddyPress and it worked 🙂 Thank you both so much for your help.

    The only thing is, now that the template is loading properly, for some reason, the BuddyPress nav and subnav bar (which was looking as it should before) has now lost its styling. Is there something that needs to be done to get the theme’s custom styling back? I tried adding this wp_dequeue_style( 'buddypress' ); to the same function but it didn’t work.


    @r-a-y
    “may I ask what URL you are attempting to load …” this is the URL i see in the browser – http://www.domain.dev/users/username/dashboard/

    “If this is a non-BuddyPress page …” as far as i can tell, it appears to be a BuddyPress page.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Templates not Loading after BP update 1.7.2 to 2.4’ is closed to new replies.
Skip to toolbar