Skip to:
Content
Pages
Categories
Search
Top
Bottom

Menu tab issue

  • Avatar of Versipellis
    Versipellis
    Participant

    @versipellis

    I am trying to add my own menu tab, and have tried several ways to do this from looking around this forum already.

    If I do the following:

    `bp_core_new_nav_item( array(
    ‘name’ => __( ‘Media Privacy’, ‘bp-media-privacy’ ),
    ‘slug’ => ‘media-privacy’,
    ‘position’ => 80,
    ‘show_for_displayed_user’ => false,
    ‘screen_function’ => ‘bp_media_privacy’,
    ‘default_subnav_slug’ => ‘media-privacy’
    ) );`

    That works and I get a tab next to ‘settings’, however when I click the link the page goes to ‘Page not Found’

    When trying to put it within a function such as:

    `add_action( ‘bp_setup_nav’, ‘Media_Privacy’);

    function Media_Privacy(){

    bp_core_new_nav_item( array(
    ‘name’ => __( ‘Media Privacy’, ‘bp-media-privacy’ ),
    ‘slug’ => ‘media-privacy’,
    ‘position’ => 80,
    ‘show_for_displayed_user’ => false,
    ‘screen_function’ => ‘bp_media_privacy’,
    ‘default_subnav_slug’ => ‘media-privacy’
    ) );

    }

    function bp_media_privacy() {

    add_action( ‘bp_template_content’, ‘bp_media_privacy_show’ );

    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );

    }

    function bp_media_privacy_show() {

    echo ‘testing the page’;

    }`

    No tab appears and I’m not sure why, this is a clean buddypress test issue and I’ve taken variants of this code from peoples examples online. However this way I cannot get the tab to show, but the other way the tab does nothing anyway?

    A little guidance would be appreciated.

    Regards,

    Versi

Viewing 14 replies - 1 through 14 (of 14 total)
  • Avatar of Versipellis
    Versipellis
    Participant

    @versipellis

    Still having an issue with this, if anyone can help?

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    Hi @versipellis,

    Make sure that you only attempt to set up the items after BP has set up its core navigation. You can ensure this by hooking to bp_setup_nav with a priority higher than 10.

    http://codex.buddypress.org/developer/plugin-development/group-extension-api/

    try this in bp-custom.php

    <code>function my_bp_nav_adder() {

    bp_core_new_nav_item(

    array(

    ‘name’ => __( ‘Media Privacy’,’bp-media-privacy’ ),

    ‘slug’ => ‘media-privacy’,

    ‘position’ => 75,

    ‘show_for_displayed_user’ => true,

    ‘screen_function’ => ‘bp_media_privacy_link’,

    ‘item_css_id’ => ‘bp-media-privacy’

    )
    );

    }

    function bp_media_privacy_link () {

    add_action( ‘bp_template_title’, ‘my_media_privacy_title’ );

    add_action( ‘bp_template_content’, ‘my_media_privacy_content’ );

    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );

    }

    function my_media_privacy_title() {

    echo ‘My Page Title’;

    }

    function my_media_privacy_content() {

    echo ‘Add the content loop here’;

    }

    add_action( ‘bp_setup_nav’, ‘my_bp_nav_adder’, 100 );

    </code>

     

    Avatar of Versipellis
    Versipellis
    Participant

    @versipellis

    Thanks for the info but even cutting and pasting your code into my file doesn’t work, no tab appears in my menu.

    I’ve never built a buddypress plugin before so I don’t really know how to set one up – is it the same as making one for wordpress or not? Currently I’m just working with a test file within my local wordpress/buddypress set up, exactly how I test my commercial plugins before actually developing them within the wordpress plugin format.

    Since this doesn’t seem to have any effect – IE, the code you gave does nothing, does it have to be within a plugin already, unlike wordpress which simply has to be accessible? If so, could you possibly link to a buddypress plugin guide (If different to wordpress itself) As I could not find a clear one myself?

    Thanks kindly,

    Versi

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    Where do you try to insert the code ? The code works if you put it in bp-custom.php (this file should be in wp-content/plugins) , i tested it before publishing here and a tab appears on the profile page.

    Copy/pasting from here is odd, take care with cotes.

    I don’t know about a good tutorial. View here and try also bp-skeleton

    http://codex.buddypress.org/developer/plugin-development/creating-a-custom-buddypress-component/

     

    Avatar of Versipellis
    Versipellis
    Participant

    @versipellis

    I’ve just put the file in with my theme – this is how I develop everything to start with on wordpress and never fails. This just means its always hard coded for my testing purposes rather than being a plugin.

    So it should just be bp-custom.php on it’s own in the plugin folder? There is no special code like in wordpress to give the name, uri etc?

    I had looked at the buddypress info you linked to originally and found it lacking in information, it seemed to assume you knew how to develop a buddypress plugin without actually explaining if its the same as wordpress or different.

    If the case is you cannot hardcode any buddypress code outside of a plugin I shall try a custom plugin, if you could possible answer my previous question of the plugin info code for me? Is it the same as wordpress or does it have to define it is buddypress?

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Place custom code in file bp-custom.php and place file in the plugins folder.

    Avatar of Versipellis
    Versipellis
    Participant

    @versipellis

    Yes thanks @modemlooper that has been suggested but I asked a question in regards to whether it requires the usual wordpress plugin info (plugin and author uri’s etc) or not?

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    Yes.

    did you checkek skeleton ? It’s a good starting point.

    http://wordpress.org/extend/plugins/buddypress-skeleton-component/

    Avatar of Versipellis
    Versipellis
    Participant

    @versipellis

    Yes but since its not designed for functional use I didn’t bother looking further. The plugin I’m developing will be small anyway, only a single page most likely.

    Thank you for your help.

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    For sure, but the infos inside the plugin are important to know, and i recommand you to read them, to understand how a BP plugin should be built.

    Avatar of Versipellis
    Versipellis
    Participant

    @versipellis

    @chouf1 Will do, thank you.

    However, I’ve put all this into a plugin for wordpress now and activated it – I am still not getting a tab in my profile. The above code you suggested @chouf1 doesn’t display for me at all?

    Could you possible paste bin the entire plugin code for me to view to see where I am going wrong?

    Thanks

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    No. Bp-custom does not require a plugin header

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    You do not need to create a component for simple code tweaks. The skeleton plugin is an example of how you would create a new feature.

    Avatar of Versipellis
    Versipellis
    Participant

    @versipellis

    All I want to do is add a new tab to the menu, the code I’m going to be using to define what is displayed I can include elsewhere. The idea is this tab literally adds a single radio option for a user to choose an option from, then saves to a table I’ve created in my database.

    However, the skeleton component seems overly complicated for this, and the bp-custom.php way of doing things does nothing.

    No matter which example code I try, the only way I can get a tab to display is by putting:

    `bp_core_new_nav_item( array(
    ‘name’ => __( ‘Media Privacy’, ‘bp-media-privacy’ ),
    ‘slug’ => ‘media-privacy’,
    ‘position’ => 80,
    ‘show_for_displayed_user’ => false,
    ‘screen_function’ => ‘bp_media_privacy’,
    ‘default_subnav_slug’ => ‘media-privacy’
    ) );`

    By putting the above code directly into an included page it displays but doesn’t go to the said page. When I put it in a function and add it using add_action( ‘bp_setup_nav’, ‘my_bp_nav_adder’, 100 ); nothing happens at all.

    I’m seriously confused at this point but it is vital to have this additional tab in the front end for users to be able to change this setting. I’m using a clean install of the latest Buddypress on my wamp (not putting this on my live site until it works.)

    @chouf1 and @modemlooper, could someone possibly do a pastebin of an example, working, bp-custom.php as I cannot find one? Thank you for your help before.

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

You must be logged in to reply to this topic.