Skip to:
Content
Pages
Categories
Search
Top
Bottom

Setting up new tab in member profile


  • ttremain
    Participant

    @ttremain

    Hello,

    I’m working on a project and could use some assistance.

    With bp_core_new_nav_item(), I’ve created a new tab in profiles, called Projects. (See image) I just have not been able to figure out where to create a template for the contents of the tab.

    Image

    Would it have to do with the setting ‘screen_function’ ??

    Thank you in advance!

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

  • Venutius
    Moderator

    @venutius

    Yes I’ve not played with that yet but from what I can see that’s the name of the function that will be called to display your content, it can call a template file.

    Here’s an example, posted by Shanebp in the archives:

    function add_iuda_tab() {
    	global $bp;
    	
    	bp_core_new_nav_item( array(
    		'name'                  => 'Iuda',
    		'slug'                  => 'iuda',
    		'parent_url'            => $bp->displayed_user->domain,
    		'parent_slug'           => $bp->profile->slug,
    		'screen_function'       => 'iuda_screen',			
    		'position'              => 200,
    		'default_subnav_slug'   => 'iuda'
    	) );
    
    }
    add_action( 'bp_setup_nav', 'add_iuda_tab', 100 );
    
    function iuda_screen() {
        add_action( 'bp_template_title', 'iuda_screen_title' );
        add_action( 'bp_template_content', 'iuda_screen_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function iuda_screen_title() { 
    	echo 'iuda Title<br/>';
    }
    
    function iuda_screen_content() { 
    	echo 'iuda Content<br/>';
    }

    Venutius
    Moderator

    @venutius

    The bp_core_template_plugin function is loading plugins.php from the bp-templates directory, which can be overloaded by placing your own template file in themes/child-theme/buddypress/members/single/plugins.php that’s one way of doing it. another way is to register your own template directory (inside plugin for example) and tell bp to load that.


    ttremain
    Participant

    @ttremain

    I have tried the code above, here:

    
    add_action( 'bp_setup_nav', 'content_setup_nav_profile' );
    function content_setup_nav_profile() {
    	bp_core_new_nav_item( array(
    		'name' => 'projects',
    		'slug' => 'project',
    		'screen_function' => 'XX_bp_projects_screen',
    		'position' => 20,
    		'default_subnav_slug' => 'project',
    		'item_css_id' => 'projects',
    	) );
    }
    
    function XX_bp_projects_screen() {
        // We never get here for some reason
        add_action( 'bp_template_title', 'XX_bp_projects_screen_title' );
        add_action( 'bp_template_content', 'XX_bp_projects_screen_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    } //end function
    function XX_bp_projects_screen_title() {
    	echo 'Projects<br/>';
    }
    function XX_bp_projects_screen_content() {
    	echo 'Dummy Content<br/>';
    }
    

    The icon shows, in the row with the others.
    Yet, it never launches the function listed under ‘screen_function’, XX_bp_projects_screen()

    I’m perplexed..


    ttremain
    Participant

    @ttremain

    Thought I had an additional issue. ‘screen_function’ wasn’t getting reached. The theme was ALSO creating a menu item with the same slug.

    Solved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar