Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] WP_DEBUG Notice for bp_setup_current_user

  • @johnclause

    Participant

    It might have been already reported to you, I would like to post another vote to get rid of the following message:

    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 3547

    which starts showing up when BuddyPress is activated and WP_DEBUG is on in /wp-config.php. It does not seem to break functionality of BuddyPress, but it is very annoying, when one tries to debug other stuff.

    Thank you very much.

Viewing 10 replies - 1 through 10 (of 10 total)
  • @henrywright

    Moderator

    Does the notice appear with all plugins disabled using the Twenty Fifteen theme?

    @johnclause

    Participant

    You got me, Henry! No, it does not. I now have been turning on/off other plugins and I got a combination: “Twenty Fifteen”, BuddyPress and “Favicon by RealFaviconGenerator”. If I turn off either BuddyPress or Favicon, the message disappear. Do you wish me to report it to Favicon, or would you look first what exactly is wrong?

    @henrywright

    Moderator

    It’s probably worth reporting the issue to Favicon and hopefully the authors will release an update fixing the problem.

    Let us know how you get on and if you need any more info, just shout.

    @johnclause

    Participant

    While working on other plugin, I came across that this message appears when current_user_can() is called from within ‘plugins_loaded’ action. If user authentication is not expected at this point, then this proves that it is not BuddyPress problem.

    Which action, as early as possible, would you recommend to use expecting current_user_can() to work properly?

    @henrywright

    Moderator

    current_user_can() uses wp_get_current_user(). Looking at the function reference for that function, I noticed “Use the init or any subsequent action to call this function”. Take a look at the Action Reference article for the list of actions run during a typical page request. The action you use will depend on what exactly you’re doing but it looks as though the earliest available when using current_user_can() is init

    Hope this helps 🙂

    Ref:

    https://codex.wordpress.org/Function_Reference/wp_get_current_user

    https://codex.wordpress.org/Plugin_API/Action_Reference

    @johnclause

    Participant

    This is really helpful, Henry.

    I submitted a link to this thread to “Favicon by RealFaviconGenerator”.

    Thanks a lot.

    @phbernard

    Participant

    Hi,

    I’m the author of the Favicon by RealFaviconGenerator plugin.

    Just to follow up: the plugin v1.2.10 fixes the issue.

    The issue can caused by a early call to is_super_admin. This function was called to decide if some action registrations were necessary or not. The fix was to move all these to a function called upon the init action. No more warning!

    John, would you confirm you don’t have the warning anymore?

    @djpaul

    Keymaster

    Thanks @phbernard!

    @johnclause

    Participant

    Yes, all good, thank you, @phbernard!

    @phbernard

    Participant

    Great! Issue resolved! 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] WP_DEBUG Notice for bp_setup_current_user’ is closed to new replies.
Skip to toolbar