Think about what you’ve written:
The acction hook stop working if i move it from plugin file to theme’s
functions.php file
And:
bp_includes
is buddypress action and hooked onplugins_loaded
The problem is that the code stops working when you move the code to functions.php
, which is a theme file. The theme loads after plugins load and hence after plugins_loaded
. Take a look at the hook sequence for a typical page load: https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request
In fact, the first hook available to a theme is after_setup_theme
.
It sounds like your code has to be in a plugin or mu-plugin.