Add custom tab to profile page
This should be simple but haven’t been able to find info on how to do this.
I want to add a custom tab/link with content to the bbPress profile page (NOT using Buddypress at all), I’ve come across people saying it can be done, but no actual guide/info to how it can be done.
Any help appreciated. Thanks.
@deeve007 – it’s doable, but you’ll need to do some coding.
The key file you want is
create a directory on your theme called ‘bbpress’
where %your-theme-name% is the name of your theme
Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
bbPress will now use this template instead of the original
and you can amend this
you’ll see the tabs in this file.
Do come back with what you are trying to do if you need further help
I’ve been able to do that, add a link, but how do I have that link then load content that will appear in the content area and under the profile URL?
Can you outline exactly what you are aiming for eg I want a picture of fred to appear when they click a link saying ‘fred’
Why should that make a difference? Once I can find out how this is done I could add any content.
To keep it simple, let’s just say hard coded text to display, when the user clicks on a link called “Read this”.
Arguing with those trying to help you is probably not the best way forward.
How to do a link is easily googled, but I’ve put one in here that you can add to the template
<li> <span class="vcard bbp-user-profile-link"> <a class="url fn n" href="www.mysite.com/read-this" title="read this">Read this</a> </span> </li>
It was a legit question, not an argument, does it make any difference what the content is that I want to display?
And adding the link is the simple part, but after hours of googling I’ve not come across any guide to how to have that linked content appear within the user profile, rather than link away from the profile to another part of the site.
ok, I’ve spent several annoying hours trying to work out how to do this, and failed miserably!!
I expect the answer is just a few brief lines of code, and linked to the way bbpress handles both templates and wp-rewrite, but can’t fathom it out in the files
Sorry, but I am having to give up !
Thanks. Yep, tried so many things myself, seems ridiculous that this is so hard!
Only work around I can think of is to create user-details.php and user-profile.php pages, then have the links on user-detail page change content via Jquery that is on the user-profile page, in different DIVs, rather than go to separate pages. Then you could add further content to the user-profile page easy enough.
If that makes sense?
Hello! I have the same situation.
There isn’t a problem to add link to user profile navigation. But the problem is to ‘register’ that page in such way, that it contents would render properly under ‘base_url/forums/users/someuser/your-custom-page/’ url. bbPress allows to see other user’s profile info too.
I also couldn’t not find any guide how to do this or find it in plugin code. But if that page will be private (only for one user, like ‘Edit profile’ which disappears on others user acc pages) there is a workaround.
You can create page template, copy ‘single-user.php’ contents to it and create page for this template in admin. Then add a link in profile page. Also you should add filters to ‘bbp_get_user_id’ and ‘bbp_get_displayed_user_field’ to make everything work correctly on that page. (I can provide code if you’re interested).
Compared to BuddyPress, or a membership plugin like MemberPress, this is a surprisingly tedious thing to do in bbPress. I got 3/4 of the way to building it when I decided I really wanted the function on the membership account page and not in bbPress after all.
But suppose you wanted to add a tab for a page on which a user could upload an avatar using one of the many WordPress avatar plugins. Here, roughly, are the steps you would follow:
- First, you have to create the tab. This is done by adding another list-item in bbpress/templates/default/bbpress/user-details.php.
- In the other menu items on this template, you’ll notice that the href for the link is created by a function like ‘bbp_user_profile_edit_url()’. That’s because the user’s display name has to be part of the link. So, what you’ve got to do next is look in bbpress/includes/users/template.php and find that function. Then you’ve got to copy it, rename it, and modify it so that it creates the link you want (e.g., ‘/forums/users/username/avatar/’ ).
- Next, you’ve got set up bbPress to parse that link. The parsing function is bbp_parse_query(), which is found at the bottom of bbpress/includes/core/template-functions.php. This function reads the URI and sets conditional tags (e.g., ‘bbpress_is_single_user_edit’) depending on what the URI is. The function is called from bbpress/includes/core/actions.php. You’ll need to copy this function somewhere else and rename it. Then remove the action that calls it and add an action that calls your function. Then, you’ll need to modify your function such that if the URI ends in ‘avatar’ it sets a conditional tag, e.g., ‘bbpress_is_single_user_avatar’.
- Templates are loaded based on the conditional tags, and there are functions that return true or false depending on what conditional tags are present, e.g. ‘bbp_is_single_user_edit()’. These are found in bbpress/includes/common/tempate.php. You’ll have to create one of these that returns true for ‘bbpress_is_single_user_avatar’.
- Once you’ve got that, then you can conditionally load the templates you want for the page. Templates are loaded in bbpress/includes/core/template-loader.php. The function is bbp_template_include_theme_supports(). It has a filter, so you can add a conditional that loads a template when ‘bbp_is_single_user_avatar()’ is true.
As I said, I got about 3/4 of the way to doing this when I realized that it would be clearer in my application to have the avatar in the account area of my membership plugin. But I think this is roughly how you would do it in bbPress.
- You must be logged in to reply to this topic.