Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Limit Blog Creation to Admins


Burt Adsit
Participant

@burtadsit

bp itself uses the ‘plugins_loaded’ event to register it’s widgets, init it’s globals and other things. What we need to do is create a fn that listens for ‘plugins_loaded’ and do our unhooking and hooking after bp is done. In bp-custom.php we’ll need another fn called:

function my_create_a_blog_hooks(){

remove_action( ‘wp’, ‘bp_blogs_setup_nav’, 2 );

remove_action( ‘admin_menu’, ‘bp_blogs_setup_nav’, 2 );

remove_action( ‘bp_adminbar_menus’, ‘bp_adminbar_blogs_menu’, 6 );

add_action( ‘wp’, ‘my_blogs_setup_nav’, 2 );

add_action( ‘admin_menu’, ‘my_blogs_setup_nav’, 2 );

add_action( ‘bp_adminbar_menus’, ‘my_adminbar_blogs_menu’, 6 );

}

add_action(‘plugins_loaded’,’my_create_a_blog_hooks’,99);

This gets triggered on ‘plugins_loaded’ with a priority of 99. All of bp’s hooks have a priority of 10 or less so using 99 gets this fn called after all known bp hooks for ‘plugins_loaded’. Pretty safe.

Skip to toolbar