Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I create a new menu item + template to show in members component?


  • kuching
    Participant

    @substrato

    I’m trying to update an old plugin I have meant for BP ~1.3-1.6 to BP 1.7+/1.8 and use theme compatibility features.

    It’s a very simple plugin, it adds a new menu item in user profile pages and a new template to put content in it (results of a wordpress posts query – eventually with pagination). I don’t plan at this stage further actions or make content searchable

    I’ve looked at this document
    http://codex.buddypress.org/theme-compatibility/how-to-enjoy-bp-theme-compat-in-plugins/
    but I can’t figure it out. Should I extend BP_Component or BP_Members_Coponent? Perhaps I’ve missed out the right wiki? Or do you have an updated “skeleton” plugin for people to work on?

    thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,
    I’m not sure if it can help you but the following may resolve your problem :

    function my_bp_nav_adder()
    {
        bp_core_new_nav_item(
            array(
                'name' => __('New Tab Button', 'buddypress'),
                'slug' => 'all-conversations',
                'position' => 75,
                'show_for_displayed_user' => true,
                'screen_function' => 'all_conversations_link',
                'item_css_id' => 'all-conversations'
            ));
            print_r($wp_filter);
    }
    function all_conversations_link () {
        //add title and content here - last is to call the members plugin.php template
        add_action( 'bp_template_title', 'my_groups_page_function_to_show_screen_title' );
        add_action( 'bp_template_content', 'my_groups_page_function_to_show_screen_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function my_groups_page_function_to_show_screen_title() {
        echo 'My new Page Title';
    }
    function my_groups_page_function_to_show_screen_content() {
        echo 'My Tab content here';
    
    }
    add_action( 'bp_setup_nav', 'my_bp_nav_adder' );

    source: http://codex.themedelta.com/how-to-create-a-new-tab-in-buddypress-member-page/

    You have to change “members/single/plugins” by the path to your new template file without the .php extention.

    If you need to check if the action already existe for different purpose (I already need to do something similar) you can use something like this:

    if(has_action('name_of_action_to_check_for')) {
    	// action exists so execute it
    	do_action('name_of_action_to_check_for');
    } else {
    	// action has not been registered
    }

    Hope this help 😉


    kuching
    Participant

    @substrato

    Hi briKou,
    thank you – although I think that example is meant for versions earlier than 1.7? nevertheless I’ll give it a try. I was looking for something to use inside a class like in the example in the codex, but I haven’t fully understood it

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How do I create a new menu item + template to show in members component?’ is closed to new replies.
Skip to toolbar