Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP Nouveau styles not loading in child theme when logged out


  • dugost
    Participant

    @dugost

    I have BP v.9.1.1 installed under WP 5.8.2 and the site in progress is using a subdomain with its directory at the root. The directory is named as per the subdomain (i.e. subdomain.domain.tld). Unfortunately, I’m unable to share the URL.

    I’ve been wrestling with this issue for a while now. When logged in as the admin and viewing the Members Directory, the bp-nouveau-css styles (…/buddypress.min.css?ver=9.1.1) load just fine but they won’t load when logged out. This is happening specifically with an Avada child theme. I have reached out to Avada support but I’m not holding my breath for a solution from them.

    I cloned the site and began by activating the Twenty Twenty One. Like the original site, bp-nouveau-css loaded just fine when logged in or out. This was also the case for Twenty Twenty One child or the Avada parent themes. However, activating the Avada child theme prevents that stylesheet from loading.

    In my Avada child theme, I’ve only added the buddypress/members/ directories so I could make some tweaks to the listings and profile pages. The child theme’s style.css relies on the Nouveau template CSS in the BP plugin directory. With its styles missing, the page falls apart.

    I also have some custom functions in plugins/bp-custom.php but none of those deal with stylesheets.

    I’ve also tried placing the CSS folder from /buddypress/bp-templates/bp-nouveau/ in /avada-child-theme/ as a test. When logged in, bp-nouveau-css loaded from the child theme. When logged out, other BP styles were loaded from the plugin directory, not the child theme, and it still refused to load bp-nouveau-css.

    Can I add a function somewhere to enqueue the styles I need since the child theme won’t do it on its own?

    I’d actually like to add a function to only load BP’s CSS and JS where necessary since only a couple of pages use BP. I’ve found this SERT Media article but comments suggest the code won’t work with Nouveau.

    I’d greatly appreciate any help with this issue. Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)

  • dugost
    Participant

    @dugost

    Avada support said “The Avada theme does not have Nouveau theme from BB press integrated. We do have a developers item for it and I have asked our dev to push for its development.”

    Is there a method to enqueue that stylesheet specifically on the directory page?


    dugost
    Participant

    @dugost

    In case this is helpful for anyone, I was able to get an Avada child theme to enqueue BP Nouveau styles conditionally based on code detailed here placed in my child theme’s functions.php file and making sure BP Nouveau’s /css/ directory sits in the same directory.

    function register_nouveau_stylesheet() {
        wp_register_style( 'bp-nouveau-enqueue', get_stylesheet_directory_uri() . '/css/buddypress.min.css' );
    }
    add_action( 'init', 'register_nouveau_stylesheet' );
    
    function conditionally_enqueue_nouveau_stylesheet() {
        // only enqueue on members-directory page slug
        if ( is_page( 'members-directory' ) ) {
            wp_enqueue_style( 'bp-nouveau-enqueue' );
        }
    }
    add_action( 'wp_enqueue_scripts', 'conditionally_enqueue_nouveau_stylesheet' );
    

    Unfortunately, logged in users will end up loading the Nouveau stylesheet twice so I’ll have to update this code further so it checks for login status and possibly user role. Hopefully, I can find a way to conditionally enqueue BP’s styles for the directory only as well. I don’t need those styles loading site-wide!


    dugost
    Participant

    @dugost

    I’m not a coder so I’m sure this is pretty obvious to a lot of people but this seems to do the trick:

    function register_nouveau_stylesheet() {
        wp_register_style( 'bp-nouveau-enqueue', get_stylesheet_directory_uri() . '/css/buddypress.min.css' );
    }
    add_action( 'init', 'register_nouveau_stylesheet' );
    
    function conditionally_enqueue_nouveau_stylesheet() {
        // only enqueue on members-directory page slug
        if ( ! current_user_can( 'update_core' ) && is_page( 'members-directory' ) ) {
            wp_enqueue_style( 'bp-nouveau-enqueue' );
        }
    }
    add_action( 'wp_enqueue_scripts', 'conditionally_enqueue_nouveau_stylesheet' );

    The inclusion of ! current_user_can( 'update_core' ) && in the if statement prevents the stylesheet loading twice for the admin. Other user types and logged-out visitors will see the stylesheet loaded for them since Avada child theme’s currently can’t handle this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar