Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add custom tab to profile page


  • Dave
    Participant

    @deeve007

    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.

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

  • Robin W
    Moderator

    @robin-w

    @deeve007 – it’s doable, but you’ll need to do some coding.

    The key file you want is

    wp-content/plugins/bbpress/templates/default/bbpress/user-details.php

    so

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    find
    wp-content/plugins/bbpress/templates/default/bbpress/user-details.php
    Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/user-details.php

    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


    Dave
    Participant

    @deeve007

    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?


    Robin W
    Moderator

    @robin-w

    that depends.

    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’


    Dave
    Participant

    @deeve007

    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”.

    Thanks.


    Robin W
    Moderator

    @robin-w

    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>

    Dave
    Participant

    @deeve007

    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.


    Robin W
    Moderator

    @robin-w

    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 !


    Dave
    Participant

    @deeve007

    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?


    Vishnja1
    Participant

    @vishnja1

    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).


    lflier
    Participant

    @lflier

    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:

    1. First, you have to create the tab. This is done by adding another list-item in bbpress/templates/default/bbpress/user-details.php.
    2. 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/’ ).
    3. 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’.
    4. 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’.
    5. 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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar