Skip to:
Content

Opened 22 months ago

Closed 22 months ago

Last modified 19 months ago

#7001 closed defect (bug) (wontfix)

Notice: bp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init()

Reported by: yawalkarm Owned by:
Milestone: Priority: normal
Severity: normal Version: 1.7
Component: Core Keywords:
Cc: mhyawalkar@…

Description

The error can be reproduced with WordPress default themes also. Just try is_user_logged_in() check in functions.php and you will get this notice.

The issue is still not fixed. Any help is appreciated.

Change History (3)

#1 @slaFFik
22 months ago

There are a bunch of other tickets here with this same error.

#2 @r-a-y
22 months ago

  • Keywords needs-patch removed
  • Milestone 2.5.3 deleted
  • Priority changed from highest to normal
  • Resolution set to wontfix
  • Severity changed from major to normal
  • Status changed from new to closed
  • Version changed from 2.5.0 to 1.7

Thanks for the report, however you answered your own question:

Just try is_user_logged_in() check in functions.php and you will get this notice.

Using is_user_logged_in() in your theme's functions.php is too early. You should be running any type of user checks such as is_user_logged_in() on the 'set_current_user' hook or later.

Check out the action firing sequence in WordPress for more details:
https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request

Here's an example you can use in your theme's functions.php without running into the bp_setup_current_user notice:

/**
 * Do your login check on the 'init' hook.
 */
function my_user_check() {
    // Do your login check here.
    if ( is_user_logged_in() ) {
    }
}
add_action( 'init', 'my_user_check' );
Last edited 22 months ago by r-a-y (previous) (diff)

#3 @DJPaul
19 months ago

  • Component changed from API to Core
Note: See TracTickets for help on using tickets.