Jump to content

Warning: Creating default object from empty value


Stylock

Recommended Posts

Hi, does anyone have a clue how to fix the following error.

Warning: Creating default object from empty value in C:\XAMPP\htdocs\hidden\wp-content\plugins\bp-group-hierarchy\bp-group-hierarchy-actions.php on line 22

 

It's caused by this piece of code.

function bp_group_hierarchy_setup_globals()
{
global $bp, $wpdb;
/* For internal identification */
$bp->group_hierarchy->id = 'group_hierarchy'; // line 22
$bp->group_hierarchy->table_name = $wpdb->base_prefix . 'bp_group_hierarchy';
$bp->group_hierarchy->slug = BP_GROUP_HIERARCHY_SLUG;

/* Register this in the active components array */
$bp->active_components[$bp->group_hierarchy->slug] = $bp->group_hierarchy->id;

do_action('bp_group_hierarchy_globals_loaded');
}

 

That is from BuddyPress. I have nothing to do with that code.

It is just saying that it is not an object, you can solve it by defining it as a stdClass:

 

function bp_group_hierarchy_setup_globals()
{
global $bp, $wpdb;

/* Define a default class if one has not been instantiated */
if (!is_object($bp->group_hierarchy)) 
    $bp->group_hierarchy = new stdClass();

/* For internal identification */
$bp->group_hierarchy->id = 'group_hierarchy'; // line 22
$bp->group_hierarchy->table_name = $wpdb->base_prefix . 'bp_group_hierarchy';
$bp->group_hierarchy->slug = BP_GROUP_HIERARCHY_SLUG;

/* Register this in the active components array */
$bp->active_components[$bp->group_hierarchy->slug] = $bp->group_hierarchy->id;

do_action('bp_group_hierarchy_globals_loaded');
}

 

And that should get rid of the warnings. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.