#4195 closed defect (bug) (no action required)
functions tied to "init" action do not run
Reported by: | dbvista | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.5.5 |
Component: | Core | Keywords: | |
Cc: |
Description
We’re running WordPress 3.3.2. After upgrading BuddyPress to 1.5.5, some of the functions in our WordPress plugins have stopped running if they hook WordPress’s “init” action. For example, in this code:
error_log("one"); function foo() { error_log("two"); } add_action("init", "foo"); error_log("three");
the strings “one” and “three” get written to the error log (proving that the PHP file is being loaded), but “two” never happens. This problem is also mentioned on StackOverflow:
http://stackoverflow.com/questions/9895881/buddypress-wiki-component-action-on-init-not-called
Change History (4)
#2
@
13 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
The problem appears to be with the BuddyPress Wiki Component, and in particular with the way that this plugin loads itself. Its main loader function is hooked to bp_init
, which is too late. It should be hooked to bp_include
. See http://codex.buddypress.org/plugin-development/checking-buddypress-is-active/
You may consider contacting the author of the plugin, to see if he plans to update it for BP 1.5 compatibility.
#3
@
13 years ago
Thank you very much. We are not running BuddyPress Wiki, but our other plugins were also using bp_init.
#4
@
13 years ago
We are not running BuddyPress Wiki, but our other plugins were also using bp_init.
Yeah, a pretty fair number of plugins are. The truth is that using bp_init
works fine in most cases - unless you *also* try to hook an internal function to init
. (The reason is because bp_init
is itself hooked to init
at priority 10, which creates a race condition that the hooked function often loses.) This is one of the reasons why bp_include
was introduced around BP 1.2.6.
Previously we were running Version 1.2.8.