Writing a new plugin – get 404 not found when accessing screen
-
Hi there,
We’re running BuddyPress 1.2.5.2. I’ve just written a new BP component that displays BP groups in a tree format. It’s very simple – all it does is provide one screen, accessible at the slug “groupsdir”, that displays our group directory structure in a custom way. However, no matter how carefully I’ve checked and double-checked my code, trying to access /groupsdir from the WP root gives me a 404 Page Not Found error.
I’m sure my …_setup_globals() and …_setup_nav() functions are getting called at the right times (I inserted some echo statements to make sure). After those functions are called, shouldn’t BuddyPress call my specified screen function when the corresponding specified slug is called? Or is there more to it than that? I feel like I must be missing something.
Here are those functions:
`function bp_gdatree_setup_globals() {
global $bp;
$bp->groupsdir->id = ‘groupsdir’;
$bp->groupsdir->slug = BP_GDATREE_SLUG; // that slug is “groupsdir”
$bp->active_components[$bp->groupsdir->slug] = $bp->groupsdir->id;
}
add_action( ‘wp’, ‘bp_gdatree_setup_globals’, 0 );
add_action( ‘admin_menu’, ‘bp_gdatree_setup_globals’, 0 );function bp_gdatree_setup_nav() {
global $bp;/* Add ‘Conferences Directory’ to the main user profile navigation */
bp_core_new_nav_item( array(
‘name’ => __( ‘Conferences Directory’, ‘bp-gdatree’ ),
‘slug’ => $bp->groupsdir->slug,
‘screen_function’ => ‘bp_gdatree_screen_directory’,
‘show_for_displayed_user’ => false
) );
}
add_action( ‘wp’, ‘bp_gdatree_setup_nav’, 2 );
add_action( ‘admin_menu’, ‘bp_gdatree_setup_nav’, 2 );`When you navigate to /groupsdir, instead of executing the function `bp_gdatree_screen_directory()`, a 404 Page Not Found screen is displayed.
Does anyone have any advice for me? Thanks.
- The topic ‘Writing a new plugin – get 404 not found when accessing screen’ is closed to new replies.