Skip to:
Content

Opened 4 years ago

Closed 4 years ago

#2837 closed defect (wontfix)

Notice: bbp_setup_current_user was called incorrectly

Reported by: anacouto Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: API - Roles/Capabilities Keywords:
Cc:

Description

Notice: bbp_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 2.3.)

To replicate:
on a clean WP installation add and activate the following plugins: bbpress, WooCommerce, Access
the notice is triggered

I think that this problem is due to the usage of a deprecated hook since WP 3.0 by changing the hook, this problem would be solved for plugins like access and ACF.

so in includes/core/actions.php around line 48
add_action( 'set_current_user', 'bbp_setup_current_user', 10 );
replace with
add_action( 'wp_set_current_user', 'bbp_setup_current_user', 10 );

Using bbpress version 2.5.7 although this also occurs on older versions.

Let me know what you thing and if further information is needed.

Change History (2)

#1 @johnjamesjacoby
4 years ago

Hi anacouto,

Thanks for the taking the time out of your day to create your first bbPress trac ticket. I, for one, really appreciate it. You may want to check-out what WooCommerce and Access are up to, as this is not exactly a bbPress issue.

This debug notice is triggered when WP_DEBUG is on, and a plugin *other than* bbPress is attempting to access something pertaining to the current user *before* $wp->init() and/or the init action has fired in wp-settings.php. The notice is there to alert you that bbPress is being forced into a configuration that may cause other (potentially serious) access control issues that WordPress has no hooks to let properly bbPress circumvent or restore back to safe operating conditions.

Unfortunately, it's difficult to ascertain from within bbPress exactly what other plugin causes this to happen, so bbp_setup_current_user comes up in the logs.

Also, there is no wp_set_current_user action, so your recommendation will cause bbPress's current user object not to function correctly. While the wp_set_current_user() function was introduced in 2.0.3, the set_current_user action remains for backwards compatibility onwards.

See also:

  • #WP24169 regarding the Customizer also doing this wrong
  • #WP23106 regarding adding an action to allow plugins to reliably hook in and repair capabilities

#2 @johnjamesjacoby
4 years ago

  • Component changed from General to API - Roles/Capabilities
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Version changed from 2.5.7 to 2.0

I've created the following Codex page based on this response:

http://codex.bbpress.org/bbp_setup_current_user/was-called-incorrectly/

Thanks again for the report. If you have any other questions, feel free to ask them here.

Note: See TracTickets for help on using tickets.