Add extra sections to members
-
I would like to create an extra section to the members part of buddypress.
currently there is;
– activity
– profile
– blogs
– wire
– friends
– groups
How would I create another lets say ‘video’?
I would imagine I create a component but not sure how i would hook it into the members page
-
Yes, you are right.You need to create a custom component.
here is a great way to start.
Download the skeleton component from here and have a look, you will see ,how can you do it.
https://wordpress.org/extend/plugins/buddypress-skeleton-component/
cool, already looking into that now.
although (correct me if im wrong), that seems to create a standalone component accessed via;
However I was wanting to create one that ties into the users profile…. such as
http://example.com/members/some-member/my-custom-component/
Could you give me some pointers on to how I should get started?
Cheers
Well, This component is excellent at showing you how to add the links in userbar/options bar have a look at
bp_example_setup_nav() ,It is doing the same you want,but for a dummy thing.
bp_core_new_nav_item,this is the methods which allows to to add links to user bar.Investigate a little more, you will see show it works
Oh great, that was simple!
Ok so now my next question.
What would I need to do to only make this visible on certain profiles (ie ones where a certain field in xprofile_data is present)?
Currently I have the extra component visible on;
My Account on the buddybar
The Me section
and a users profile menu.
I put an if statement around the part that sets up the nav. but that doesnt work. It just either shows it in all 3 or none at all
Just to add to this, after further searching I think what I need to do is add only a menu item to the the options bar only.
Hey so I gave up in the end and will continue tonight.
Does anybody know how I can get something to the options bar of the members section with out adding it to the users bar?
hi
That thing(adding extra menu to options bar) is possible(well,I think so),But The options bar is component dependent when a user is logged in and is on his/her profile.So how do you plan to add extra item to option bar,for which component you want to add this extra nav there ?
OK basically I want to do this;
Add an item to the optionbar for this;
http://example.org/members/XXXXX/
So when I’m viewing someone elses profile I would like to add an item to the options bar which by defualt includes;
Activity
Profile
Blogs
Wire
Friends
Groups
I don’t want to add the new item to the usersbar or the buddy bar
ok,so here you go.
The links are displayed by
bp_get_displayed_user_nav()
You can modify it using the following code inside your functions.php
global $bp;
if(!bp_is_home())
$bp->bp_nav[110]=array ( 'name' => 'test','link' => 'test/', 'css_id' =>'test','show_for_displayed_user' => 1 ,'position' => 110 );replace test with your link/component name
Then create some function to handle the link,as shown in the example component.
Again remember,when you are viewing other’s profile ,the function
bp_get_loggedin_user_nav()
and
bp_get_displayed_user_nav()
Uses same global variable
$bp->bp_nav
to render the navigation,so The link will appear in the userbar for logged in user and in the options bar for the displayed profile.
Have a look at the code of the two above mentioned methods to look for a workaround.
cheres brajesh. will have a go with those now
great
Man this one is still killing me!
the code you have given me works. but it puts the link in all 3 levels (buddybar, userbar & options bar)
After looking in the docs $bp->bp_users_nav seems to do what i want (which apparently works the same as $bp-bp_nav)
However nothing gets returned
hey,well,I guess,A little experimentation is required.
I am leaving for today ,so will take a look at it tomorrow and post the sample.
anyone else till then ,if you know post please,
no luck with this yet mate. What ever I do seems to add the link to both the userbar and options bar!
- The topic ‘Add extra sections to members’ is closed to new replies.