#2804 closed defect (bug) (invalid)
Receiving “Notice” in back-end for set_current_user hook
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | minor | Version: | |
Component: | General | Keywords: | |
Cc: |
Description
Hey bbPress Gang,
I just wanted to report a minor issue of a Notice that is being thrown for the hook in actions.php on line 48:
add_action( 'set_current_user', 'bbp_setup_current_user', 10 );
I handled it in the core plugin like this:
add_action( 'plugins_loaded', function() {
remove_action( 'set_current_user', 'bbp_setup_current_user', 10 );
add_action( 'wp_set_current_user', 'bbp_setup_current_user', 10 );
});
For your issues team, here is the notice:
Notice: bbp_setup_current_user was called <strong>incorrectly</strong>. The current user is being initialized without using $wp->init(). Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 2.3.) in /Users/tonya/Sites/sandbox/wp-includes/functions.php on line 3560
Looking at set_current_user, it was depreciated.
Simple fix:
add_action( 'wp_set_current_user', 'bbp_setup_current_user', 10 );
Attachments (1)
Change History (5)
#3
in reply to:
↑ 2
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Replying to thebrandonallen:
Thanks for the patch @hellofromTonya, however it doesn't actually fix the issue, since the
wp_set_current_user
hook doesn't exist.
Are you using any plugins, themes, or code in your theme's functions.php that might be calling wp_set_current_user()?
You are correct about the patch.
Root Cause:
In the child theme, we are checking is_user_logged_in() which then follows the callback path to call bbp_setup_current_user. This call to is_user_logged_in(), one is unnecessary and (2) occurs off of genesis_init and not init or after_theme_setup; hence, we get the notice thrown.
bbPress is properly protecting itself from said issue.
Therefore, this ticket should be closed with no further action.
Thanks for the patch @hellofromTonya, however it doesn't actually fix the issue, since the
wp_set_current_user
hook doesn't exist.Are you using any plugins, themes, or code in your theme's functions.php that might be calling wp_set_current_user()?