Skip to:
Content
Pages
Categories
Search
Top
Bottom

buddypress profile new tab returns permission denied

  • Avatar of blakemacnair
    blakemacnair
    Participant

    @blakemacnair

    I’m trying to add a new tab to the profile page on Buddypress, I’ve successfully added the page, but when I click on the tab it returns “Permission Denied. Not Found / No Access”. I’m using a child theme of BuddyPress Social, here’s the code I’m trying to use:

    
    add_action( 'bp_setup_nav', 'my_test_setup_nav' );
    function my_test_setup_nav() {
        global $bp;
    
        $parent_slug = 'style';
        $child_slug = 'style_sub';
    
        //name, slug, screen, position, default subnav
        bp_core_new_nav_item( array( 
            'name' => __( 'Test' ), 
            'slug' => 'test', 
            'parent_url' => $bp->loggedin_user->domain . $bp->slug . '/', 
            'parent_slug' => $bp->slug, 
            'screen_function' => 'my_profile_page_function_to_show_screen', 
            'position' => 40
        ) );
    
        function my_profile_page_function_to_show_screen() {
            //add title and content here - last is to call the members plugin.php template
            add_action( 'bp_template_title', 'my_profile_page_function_to_show_screen_title' );
            add_action( 'bp_template_content', 'my_profile_page_function_to_show_screen_content' );
    
            bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
        }
    
        function my_profile_page_function_to_show_screen_title() {
            echo '<div style="text-align:left;">Test Page</div>';
        }
        function my_profile_page_function_to_show_screen_content() { 
            echo '<div>hello world!</div>';
        }
    }
    

    Note: this is on an offline development server ATM, running WP version 3.5.2 and BP version 1.8.1

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    Try adding this to the bp_core_new_nav_item array:

    'position'        => 40,
    'user_has_access' => bp_is_my_profile(),
    'default_subnav_slug' => 'test'
    Avatar of blakemacnair
    blakemacnair
    Participant

    @blakemacnair

    Sorry for the late response, but nope, that didn’t do it, still giving me the same error page.

    Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    Try these changes:

    	'parent_url'      => $bp->loggedin_user->domain . '/',
    	'parent_slug'     => $bp->profile->slug,
    Avatar of blakemacnair
    blakemacnair
    Participant

    @blakemacnair

    Nope, still no dice, have no idea what’s causing this problem

    Avatar of 4ella
    4ella
    Participant

    @4ella

    This is my working new tab in bp-custom.php if this helps

    // Set up Custom BP navigation
    function my_setup_nav() {   
       if ( user_can( bp_displayed_user_id(), 'job_applicant' ) ) {  
       global $bp;
          bp_core_new_nav_item( array(
                'name' => __( 'Portfolio', 'buddypress' ),
                'slug' => 'portfolio',
                'position' => 20,
                'screen_function' => 'profile_screen_portfolio' 
          ) );
    
          // Change the order of menu items
          $bp->bp_nav['messages']['position'] = 100;
      }
    }
    
    add_action( 'bp_setup_nav', 'my_setup_nav' );
    
    // show portfolio when 'Portfolio' tab is clicked
    function profile_screen_portfolio() {
    add_action( 'bp_template_content', 'profile_screen_portfolio_show' );
    bp_core_load_template( 'members/single/plugins' );
    }
    
    function profile_screen_portfolio_show() {
    
    // call your stats template
    locate_template( array( 'portfolio-profile.php' ), true );
    
    }
Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.