Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating a page with nav tab, subnav for Buddypress profiles

Viewing 17 replies - 1 through 17 (of 17 total)
  • @chrisclayton

    Participant

    @tiagobeloto – It should work.
    The code from defunctlife in that thread works perfectly as a copy/paste except for the missing $dispuser variable…

    What’s the exact code your using?

    @anonymized-8418620

    Inactive

    I’m using this code:

    `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’;

    }
    }
    add_action( ‘bp_setup_nav’, ‘my_test_setup_nav’ );`

    But active only a new tab in profiles, but don’t active a subnav… Can you help me?

    @anonymized-8418620

    Inactive

    @chrisclayton

    Participant

    @tiagobeloto – sorry for the late reply (had afew problems with my own site yesterday :( ) i don’t think $bp->slug is a proper variable.

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

    http://pastebin.com/g4X3wRph

    @anonymized-8418620

    Inactive

    @ChrisClayton Ok, don’t worry.
    I entered in that link that you posted, and i put the code in functions.php. The tab “test” was created, but when I click on the “Home” tab or create a new tab and I click it, enter into an error page. How do I run the pages subnavs?

    @chrisclayton

    Participant

    Woops. Change the parent_url to ` ‘parent_url’ => trailingslashit( bp_displayed_user_domain() . ‘test_sub’ )`

    @anonymized-8418620

    Inactive

    @ChrisClayton I tested with it and still seems an error page. Can you give the complete code?

    @chrisclayton

    Participant

    Here you go.
    http://pastebin.com/JuTEZ8GB

    Tested this on my local install of BP, so should work.

    @anonymized-8418620

    Inactive

    @ChrisClayton Thank you so much! It worked perfectly, thank you really. One last thing (to stop to being boring with you!! I’m??):
    I’m wanting to make a new tab and a new subnav to show posts in the profile of each user in BuddyPress. Ex.:
    If I made x posts, that will appear in that subnav my posts. I did this, it worked, but one thing: when you access a profile of another person, this tab will appear my posts, but the posts that should appear is of the person I’m visiting the profile. Why is this happens?

    Code that I used is the same loop of author.php themes:

    https://codex.wordpress.org/Author_Templates

    @chrisclayton

    Participant

    woops, just noticed that i accidentally put in $bp->loggedin_user->domain – Sorry! change it to – $bp->displayed_user->domain

    Should fix your issue assuming that it’s grabbing the author name correctly in the ‘loop’. [haven’t tested it] If it doesn’t work you may need to use (off the top of my head)

    `<?php
    $args = array( ‘author’ => bp_displayed_user_id() );

    $the_query = new WP_Query( $args );

    // The Loop
    if ( $the_query->have_posts() ) :
    while ( $the_query->have_posts() ) : $the_query->the_post();
    // Do Stuff (This is where you would put the_title, the_content etc. whatever you want to show)
    endwhile;
    endif;

    // Reset Post Data
    wp_reset_postdata();
    ?>`

    @anonymized-8418620

    Inactive

    @ChrisClayton Thank you very much, worked perfectly! =D Do you have any mail for us to talk about programming (gtalk)?
    Since we are speaking of tabs, how do I change places, for example: the subnav Edit from Profile tab to the Settings tab?

    @anonymized-8418620

    Inactive

    @ChrisClayton Another thing about loop posts you gave to me and that only now I saw: I tested, everything worked out, but it appears only a certain amount of posts made that author, correct. But there is a link to show more of that author’s posts, in the tab?

    @anonymized-8418620

    Inactive

    @ChrisClayton Could you help me with these two post up??

    @chrisclayton

    Participant

    Sorry, missed your replies…

    “Since we are speaking of tabs, how do I change places, for example: the subnav Edit from Profile tab to the Settings tab?”
    bp_core_sort_subnav_items() should help.

    You can change how many posts show up from the user with `’posts_per_page’ => 10,` (i would tell you how to do pagination, but WordPress makes those things a pain in the butt when your not on a ‘wordpress’ page).

    @anonymized-8418620

    Inactive

    @ChrisClayton I tested the code pages, as you said, WordPress does not allow navigation on pages other than WordPress, but ok! But the code: bp_core_sort_subnav_items () did not work, could you give me the complete code on how to change the subnav position form a tab to another tab? Thanks!!!

    @anamika_11

    Participant

    hii, i tried your code in functions.php but after running it, gives error test member/djadmin/test/” not found will u plz tell me what is the solution

    @anamika_11

    Participant

    I want to add a new tab beside the group tab and when i click on that tab it dives the related info in <item body> tad just like group and profile page

Viewing 17 replies - 1 through 17 (of 17 total)
  • The topic ‘Creating a page with nav tab, subnav for Buddypress profiles’ is closed to new replies.
Skip to toolbar