Re: Limit Blog Creation to Admins
What I’m describing here is one method to alter bp’s behavior without modifying the core code. You can replace *any* bp function that responds to an action with the procedure similar to the one above.
1) Determine where in the code your modification must be made. If the function that you need to modify is triggered by an action with something like: add_action(‘some_action’,’the_function_i_want_to_modify’); then you can replace it and modify the code to your hearts content.
2) Make a copy of the function, calling it something else of course.
3) Unhook the original function, preventing it from responding to the action.
remove_action('some_action','the_function_i_want_to_modify')
4) Hook your new function in the same manner as the old function. Replacing the call to the original function with a call to your new function.
add_action('some_action','my_replacement_function')
5) Make changes to the replacement function that suits you.
One tip here. Functions get registered with wp to respond to actions with the add_action() call. The format you’ll see quite alot is:
add_action('action_name_to_hook', 'function_to_call')
You will also see:
add_action('action_name_to_hook', 'function_to_call', 99)
The 99 at the end there is the priority for the function call ‘function_to_call’. Think of it like this. If more than one function wants to hook ‘action_name_to_hook’ then wp queues them up and executes those functions in the order in which they were registered. To control when a function gets triggered by an action, the priority is taken into account.
Functions with priority 1 get triggered before functions with priority 10. If a bp function registers itself with an action and specifies a priority then the only way to remove that function and replace it is to specify the removal with the same priority.
The call above to add_action(…, 99) can only be removed with a remove_action(…, 99)