Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackWordPress/status/1085824158662094848
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Removed info not related to the question
Source Link
EpF
  • 121
  • 1
  • 1
  • 7

I'm getting an error from BuddyPress that seemsSpecifically, is it valid to be being triggered by creatingrun a new WP_Query() during the plugins_loaded action. The query runs fine and does what I want, but I'd like to know if I'm doing it wrong, or if BP is in error here.

Alternatively, is there a parameter I can pass to the query to tell it not to try to retrieve user info? I couldn't see anything in the documentation for the class, but then the no_found_rows parameter isn't documented there either.

The BP error is:

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

My plugin includes a class that includes the following code in the __construct() method:

add_action('plugins_loaded', array($this, 'getDocs'));

This is the getDocs() method:

public function getDocs()
{
    $args = array(
        'posts_per_page' => -1,
        'post_type' => 'document',
        'no_found_rows' => true,
        'fields' => 'ids',
    );
    $docs = new WP_Query($args);
    wp_reset_query();
    $this->docs = $docs->posts;
}

I'm getting an error from BuddyPress that seems to be being triggered by creating a new WP_Query() during the plugins_loaded action. The query runs fine and does what I want, but I'd like to know if I'm doing it wrong, or if BP is in error here.

Alternatively, is there a parameter I can pass to the query to tell it not to try to retrieve user info? I couldn't see anything in the documentation for the class, but then the no_found_rows parameter isn't documented there either.

The BP error is:

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

My plugin includes a class that includes the following code in the __construct() method:

add_action('plugins_loaded', array($this, 'getDocs'));

This is the getDocs() method:

public function getDocs()
{
    $args = array(
        'posts_per_page' => -1,
        'post_type' => 'document',
        'no_found_rows' => true,
        'fields' => 'ids',
    );
    $docs = new WP_Query($args);
    wp_reset_query();
    $this->docs = $docs->posts;
}

Specifically, is it valid to run a new WP_Query() during the plugins_loaded action?

Added error text and code explanation
Source Link
EpF
  • 121
  • 1
  • 1
  • 7

I'm getting an error from BuddyPress that seems to be being triggered by creating a new WP_Query() during the plugins_loaded action. The query runs fine and does what I want, but I'd like to know if I'm doing it wrong, or if BP is in error here.

Alternatively, is there a parameter I can pass to the query to tell it not to try to retrieve user info? I couldn't see anything in the documentation for the class, but then the no_found_rows parameter isn't documented there either.

The BP error is:

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

My plugin includes a class that includes the following code in the __construct() method:

add_action('plugins_loaded', array($this, 'getDocs'));

This is the getDocs() method:

public function getDocs()
{
    $args = array(
        'posts_per_page' => -1,
        'post_type' => 'document',
        'no_found_rows' => true,
        'fields' => 'ids',
    );
    $docs = new WP_Query($args);
    wp_reset_query();
    $this->docs = $docs->posts;
}

I'm getting an error from BuddyPress that seems to be being triggered by creating a new WP_Query() during the plugins_loaded action. The query runs fine and does what I want, but I'd like to know if I'm doing it wrong, or if BP is in error here.

Alternatively, is there a parameter I can pass to the query to tell it not to try to retrieve user info? I couldn't see anything in the documentation for the class, but then the no_found_rows parameter isn't documented there either.

I'm getting an error from BuddyPress that seems to be being triggered by creating a new WP_Query() during the plugins_loaded action. The query runs fine and does what I want, but I'd like to know if I'm doing it wrong, or if BP is in error here.

Alternatively, is there a parameter I can pass to the query to tell it not to try to retrieve user info? I couldn't see anything in the documentation for the class, but then the no_found_rows parameter isn't documented there either.

The BP error is:

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

My plugin includes a class that includes the following code in the __construct() method:

add_action('plugins_loaded', array($this, 'getDocs'));

This is the getDocs() method:

public function getDocs()
{
    $args = array(
        'posts_per_page' => -1,
        'post_type' => 'document',
        'no_found_rows' => true,
        'fields' => 'ids',
    );
    $docs = new WP_Query($args);
    wp_reset_query();
    $this->docs = $docs->posts;
}
Source Link
EpF
  • 121
  • 1
  • 1
  • 7

new WP_Query() - what is the earliest valid hook?

I'm getting an error from BuddyPress that seems to be being triggered by creating a new WP_Query() during the plugins_loaded action. The query runs fine and does what I want, but I'd like to know if I'm doing it wrong, or if BP is in error here.

Alternatively, is there a parameter I can pass to the query to tell it not to try to retrieve user info? I couldn't see anything in the documentation for the class, but then the no_found_rows parameter isn't documented there either.