Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I add a menu item on the profile page?

  • Avatar of Jens Wedin
    Jens Wedin
    Participant

    @jedisthlm

    Hi I’m trying to create a new page under the profile page and wonder how to do this?
    I have a look in the codex but I am probably doing something wrong. Here is the code
    I found. I tried to add this into the functions.php and the bp_functions.php. Is this
    the correct way or should I do someting else?
    `
    function reviews_setup_nav() {
    global $bp;
    bp_core_new_nav_item( array(
    ‘name’ => __( ‘Reviews’, ‘buddypress’ ),
    ‘slug’ => $bp->reviews->slug,
    ‘position’ => 80,
    ‘screen_function’ => ‘reviews’,
    ‘show_for_displayed_user’ => true
    ) );

    }

    add_action( ‘wp’, ‘reviews_setup_nav’, 2 );
    `

    Here is an profile page on my site:

    http://chwisgi.com/members/jenswedin/activity/

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

    @gunju2221

    Just creating new profile page category from my understanding??? Just to go your buddypress admin page under profile setup and create new fields there, no need to hook anything.

    P.S, why on your activity page is the header content below the avatar? Go into your theme’s CSS file and remove

    `div#item-header div#item-header-content {
    float:left;
    }`

    To clear things up, it should look a-lot nicer.

    Avatar of Jens Wedin
    Jens Wedin
    Participant

    @jedisthlm

    Thank @Virtuali (@gunju2221) for the answer. I am not sure we understand each other. Let’s take this page

    http://chwisgi.com/members/jenswedin/profile/
    The navigation with tabs has ;

    * Activity
    * Profile
    * Friends (29)
    * Groups (11)

    What I am trying to do is adding a new page and a navigation tab. So it would say

    * Activity
    * Profile
    * Friends (29)
    * Groups (11)
    * Reviews (12)

    Would that be hard the create?

    And thank for the css hickup :)

    Thanks again,
    Jens

    Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    Of coarse, simple. I’m understanding you now, just add another tab right?

    Adding the screen function will add the tab next to your profile markup tab: Add to bp-custom.php. You were almost correct on your first approach. :)

    `function my_test_setup_nav() {
    global $bp;
    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 ) );

    bp_core_new_subnav_item( array( ‘name’ => __( ‘Home’ ), ‘slug’ => ‘test_sub’, ‘parent_url’ => $bp->loggedin_user->domain . $bp->slug . ‘/’, ‘parent_slug’ => $bp->slug, ‘parent_slug’ => $bp->slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen’, ‘position’ => 20, ‘item_css_id’ => ‘test_activity’ ) );

    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 ‘something’;
    }
    function my_profile_page_function_to_show_screen_content() {

    echo ‘weee content’;

    }
    }`

    Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    Wait… do you mean a subnav? Like for instance, under profile, the subtabs are “Edit Profile, and Change Cignature?”

    Could be done, wrap the bp_core_new_subnav_item call in a function which is hooked on xprofile_setup_nav action;

    `/* Add the subnav items */
    bp_core_new_subnav_item( array( ‘name’ => __( ‘My Friends’, ‘buddypress’ ), ‘slug’ => ‘my-friends’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_my_friends’, ‘position’ => 10, ‘item_css_id’ => ‘friends-my-friends’ ) );
    bp_core_new_subnav_item( array( ‘name’ => sprintf( __( ‘Requests (%d)‘, ‘buddypress’ ), bp_friend_get_total_requests_count() ), ‘slug’ => ‘requests’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_requests’, ‘position’ => 20, ‘user_has_access’ => bp_is_my_profile() ) );

    if ( $bp->current_component == $bp->friends->slug ) {
    if ( bp_is_my_profile() ) {
    $bp->bp_options_title = __( ‘My Friends’, ‘buddypress’ );
    } else {
    $bp->bp_options_avatar = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘thumb’ ) );
    $bp->bp_options_title = $bp->displayed_user->fullname;
    }`

    There ya go, 2 in one! ;)

    Avatar of Jens Wedin
    Jens Wedin
    Participant

    @jedisthlm

    Thank Virtuali (@gunju2221). I really appreciate it, I will have a look at the code as soon as possible. Thanks again :)

    Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    Your welcome ;)

    Avatar of Jens Wedin
    Jens Wedin
    Participant

    @jedisthlm

    Hi again

    I tried your first code but nothing happens? I copied your code directly and pasted into bp-custom.php.
    Just to let you know, I’m noob at coding. I also use WP 2.9.2 and BP 1.2.4.1.

    Avatar of Jens Wedin
    Jens Wedin
    Participant

    @jedisthlm

    Virtuali (@gunju2221) Sorry for bumping, not sure you have seen my answer. Any clue why it ain’t working?

    Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    Sorry for missing you. Could be outdated code, I’ll look at it this afternoon and write you a better solution

    Avatar of James
    James
    Participant

    @janismo

    hi guys, I’ve been searching for this info too. tried to write function myself on the base of buddypress followers, but without any success. If someone will get it done, please mention me in reply, thanks.

    Avatar of Jens Wedin
    Jens Wedin
    Participant

    @jedisthlm

    Virtuali (@gunju2221) Thanks!

    Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    Try:

    `bp_core_new_subnav_item( array(
    ‘name’ => ‘My New Page’,
    ‘slug’ => ‘my-new-page’,
    ‘parent_url’ => $bp->loggedin_user->domain . $bp->members->slug . ‘/’,
    ‘parent_slug’ => $bp->members->slug,
    ‘screen_function’ => ‘my_members_page_function_to_show_screen’,
    ‘position’ => 40 ) );`
    You can change the slug and name by the “slug” => and ‘name’ =>

    Then the screen function

    `function my_members_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_members_page_function_to_show_screen_title’ );
    add_action( ‘bp_template_content’, ‘my_members_page_function_to_show_screen_content’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
    }

    function my_members_page_function_to_show_screen_title() {
    echo ‘My Page Title’;
    }
    function my_members_page_function_to_show_screen_content() {

    // page content goes here

    }`

    Not tested.

    Hi Jens,

    Did you finally get it? I am trying the same.

    Thanks!

    Avatar of 4ella
    4ella
    Participant

    @4ella

    Me too , I would like to have another “extra tab” next to the PROFILE tab in member profiles with content (Fashion Model statistics with picture of the model body silhouette with girl’s measures)

    Activity | Profile | “Extra TAB” | Friends (0) | Groups (2) | Events (0) | Gallery (2)

    I was trying to use codes above but I have no idea how to make it work

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

You must be logged in to reply to this topic.