Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Fatal error with custom members nav item  #33

@adiloztaser

Description

@adiloztaser

I have a custom navigation item for members component. It occours a fatal error when BP-Rewrites is active. The reason of this error nav property creating just for admin requests. Is there any reason to do it?

// Initialize the Members Nav for WP Admin context.
if ( is_admin() && ! wp_doing_ajax() ) {
$this->nav = new \BP_Core_Nav();
}

Here is my mu-plugin to see the fatal error:

<?php
namespace NefisYemekTarifleri\Custom_Nav;

add_action( 'bp_init', __NAMESPACE__ . '\\init', 999999 );
function init() {
	if ( function_exists( 'bp_core_new_nav_item' ) ) {
		bp_core_new_nav_item(
			array(
				'name'            => 'Custom Nav',
				'slug'            => 'custom-nav',
				'parent_slug'     => buddypress()->members->slug,
				'position'        => 10,
				'screen_function' => __NAMESPACE__ . '\\custom_nav_screen',
			)
		);
	}
}

function custom_nav_screen() {
	do_action( 'bp_members_screen_display_profile' );
	bp_core_load_template( apply_filters( 'bp_members_screen_display_profile', 'members/single/home' ) );
}

Error:

Fatal error: Uncaught Error: Call to a member function add_nav() on null
in /var/www/html/wp-content/plugins/buddypress/src/bp-core/bp-core-buddybar.php on line 172

Metadata

Metadata

Assignees

Labels

backward compatibilityThe issue is about broken compatibility with a theme/plugin/custom code

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions