Skip to:
Content
Pages
Categories
Search
Top
Bottom

Getting “Page Not Found” When Attempting To Create A Top Level Page via Plugin

  • Avatar of Dimensionmedia
    David Bisset
    Participant

    @dimensionmedia

    Howdy all. I’m attempting to write a plugin that adds a main level (next to members or blogs or groups) navigation tab. I managed to get the page not to redirect to the homepage and the tab shows up active on the page, but getting a “Page Not Found” in the content area.

    I’ve reviewed this thread and others similar like it:
    http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/writing-a-new-plugin-get-404-not-found-when-accessing-screen/

    But still stuck. I know how to add submenus to profiles and groups, etc. But this particular thing i’m working on has me stumped. Even looked at @DJPaul‘s achievement plugin for hints.
    I have checked and I see my ‘cinvite’ in root_components and active_components when I do a print_r of $bp. I do have a index.php file in the /wp-content/plugins/bp-community-invite/includes/templates/ folder as well.

    Here are the trimmed down files:


    /wp-content/plugins/bp-community-invite/loader.php


    // You can override these in wp-config.php.
    if ( !defined( ‘COMMUNITY_INVITE_SLUG’ ) )
    define ( ‘COMMUNITY_INVITE_SLUG’, __( ‘cinvite’, ‘cinvite’ ) );

    function bpci_init() {
    require( dirname( __FILE__ ) . ‘/includes/bp-community-invite-core.php’ );
    do_action( ‘bpci_init’ );
    }
    add_action( ‘bp_include’, ‘bpci_init’ );


    /wp-content/plugins/bp-community-invite/includes/bp-community-invite-core.php



    function bpci_setup_globals() {
    global $bp;
    $bp->cinvite->id = ‘cinvite’;
    $bp->cinvite->slug = COMMUNITY_INVITE_SLUG;
    $bp->active_components[$bp->cinvite->slug] = $bp->cinvite->id;
    }
    add_action( ‘bp_setup_globals’, ‘bpci_setup_globals’ );

    function bpci_setup_root_component() {
    bp_core_add_root_component( COMMUNITY_INVITE_SLUG );
    }
    add_action( ‘bp_setup_root_components’, ‘bpci_setup_root_component’ );

    function bpci_setup_nav() {
    global $bp;
    // Add ‘Achievements’ to the main navigation
    bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Invites (%s)‘, ‘cinvite’ ), ‘XXX’ ), ‘slug’ => $bp->cinvite->slug, ‘position’ => 80, ‘screen_function’ => ‘bpci_screen_waiting_list’, ‘default_subnav_slug’ => ”, ‘item_css_id’ => $bp->cinvite->id ) );

    }
    add_action( ‘bp_setup_nav’, ‘bpci_setup_nav’ );

    function bpci_add_to_site_nav() {
    global $bp;
    ?>
    <licinvite->slug ) ) : ?> class=”selected”>
    <a href="/cinvite->slug ?>/”>

    <?php
    }
    add_action( ‘bp_nav_items’, ‘bpci_add_to_site_nav’ );

    function bpci_setup_nav_directory() {
    global $bp, $is_member_page;

    if ( $bp->current_component == $bp->cinvite->slug ) {
    // $bp->is_directory = true;
    do_action( ‘bpci_setup_nav_directory’ );
    bp_core_load_template( apply_filters( ‘bpci_template_directory’, ‘index’ ) );
    return;
    }
    }
    add_action( ‘wp’, ‘bpci_setup_nav_directory’, 2 );



    I think i might be getting confused regarding screen functions. I did try to add the following code so that I have a function that matched the screen function i was referring to to bp_core_new_nav item:

    function bpci_screen_waiting_list() {
    do_action( ‘bpci_screen_waiting_list’ );
    bp_core_load_template( apply_filters( ‘bpci_template_directory’, ‘index’ ) );
    }

    But that did nothing.

    Open to suggestion. I bow before the mighty BuddyPress overlords on this one.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    So, you’ve managed to output the tab but cannot get the link to work?

    Have you looked at the Skeleton Component–in particular in bp-example-core.php at the function bp_example_load_template_filter() and the section below that entitled “Screen Functions”?

    Avatar of Dimensionmedia
    David Bisset
    Participant

    @dimensionmedia

    @Jeff Sayre,

    Thanks for your help on this. I’ve been working this past week… I actually was looking at the skeleton component for clues, but because it didn’t offer an example for a top-level menu item I guess it wasn’t clicking for me. I managed to create a skeleton plugin just to show off how to add a top-level menu item (for learning purposes only) and i’ll post that in the forum this week after I recover from the holidays. I actually learned alot by looking at the skeleton component and Pauls’ achievements plugin. :)

    Yay! ;)

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.