Skip to:

Re: Limit Blog Creation to Admins

Burt Adsit


So now we know what actions trigger the display fn’s for ‘Create a Blog’. Somewhere in those two fn’s is the code that displays that menu item. I guess there’s a bunch of different ways to solve this issue once we get to this point. I’m going to create two new fn’s that replace the current ones and wrap the menu option display lines in some user role detection code. If we decide that the current user can see the option then it gets displayed.

First we create two new functions in bp-custom.php that are copies if the current fn’s but with a different name. Copy bp_blogs_setup_nav() and bp_adminbar_blogs_menu() to bp-custom.php and rename them my_blogs_setup_nav() and my_adminbar_blogs_menu().

Now we have to unhook bp’s hooks for those two menus and replace them with our hooks to our new my_…() fns. The trick is to allow bp to fire up completely and before anything else happens unhook the fns.

bp is a plugin and during the wp init/startup process it loads all the plugins, executes any code that isn’t part of a fn and then triggers a few actions that signal to plugins what spot in the startup sequence it’s in and then goes on it’s merry way doing what the user wanted like loading a template file and executing it.


Skip to toolbar