Forum Replies Created
-
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.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!
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?