Dashboard Warning and fix (bp_setup_current_user)
-
Developers, could you tell me if the fix below is OK?
PROBLEM. I set WP_DEBUG true and saw this warning:
Notice: bp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init(). Please see Debugging in WordPress for more information. (This message was added in version 1.7.) in /…/wp-includes/functions.php on line 3370
Further debugging led to this pretty obvious coding error in Buddypress Wall, in
/wp-content/plugins/buddypress-wall/includes/bp-wall-loader.php
:class BP_Wall { ... function __construct( $options = null ) { ... $this->includes(); ... } function includes() { ... if ( is_super_admin() && ( is_admin() || is_network_admin() ) ) { ... } }
FIX. As a fix I wrapped the code starting at
is_super_admin
in a function and called it with an ‘init’ action.class BP_Wall { ... function __construct( $options = null ) { ... $this->includes(); add_action( 'init', array($this, 'xxx_fix'), 10 ); ... } function includes() { ... } function xxx_fix() { if ( is_super_admin() && ( is_admin() || is_network_admin() ) ) { ... } }
Will everything work OK? I can’t imagine the current code works at all.
A case where WP_DEBUG has really found a problem!
- The topic ‘Dashboard Warning and fix (bp_setup_current_user)’ is closed to new replies.