I have a forums page that displays my forum index. Whenever I add the following part of code the bbpress doesn’t display my forum index and there is a screen that only includes some text and a search option.
//This function is used to validate that firstly all the plugins are loaded because current_user_can() is a pluggable function.
function pluggable_validator(){
//Check if user is admin, if he is not then run the following functions inside the else condition
if (!current_user_can( 'administrator' )) {
//remove WordPress logo from the toolbar
function remove_wp_logo( ) {
global $wp_admin_bar;
$wp_admin_bar->remove_node( 'wp-logo' );
}
add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );
//remove WordPress sitename from the toolbar
function site_name(){
global $wp_admin_bar;
$wp_admin_bar->remove_node('site-name');
}
add_action('admin_bar_menu', 'site_name', 999);
}
}
//This is the hook that is required for pluggable functions to work.
add_action('plugins_loaded','pluggable_validator');
Read more here: bbpress doesn’t work when certain code is added in an activated plugin