Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profile Tabs

  • How do you add a tab to the three tabs – “Profile”, “Edit” and “Favourites” – visible only in the profile? I want to add a tab for the avatar and am fairly sure there’s a hook bb_profile_menu but I’m not sure what to do with it. The API certainly supports adding them, the code’s there, but I’m not sure how to do it. Anyone know?

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

  • Sam Bauers
    Participant

    @sambauers

    Look at the function global_profile_menu_structure.

    You just need to create a function that pulls in the array variable $profile_menu as a global. Then add to that array in the manner specified in the comments of the function global_profile_menu_structure.

    Should be downhill from there.

    p.s. Would be nice if you could add an entry for it at bbPulp when you are done.

    Cheers Sam, that’s definitely the way to do it, but I can’t quite make it work. Adding the tab is easy, but following the link dumps you on the front page (if using add_profile_tab()) or in your profile (if adding the tab manually).

    function felavatartab()
    {
    global $profile_menu, $profile_hooks;
    $profile_tab = array(__('Avatar'), 'edit_profile', 'moderate', 'avatar-upload.php', 'avatar');
    $profile_menu[] = $profile_tab;
    if ( can_access_tab( $profile_tab, bb_get_current_user_info( 'id' ), $user_id ) )
    $profile_hooks[bb_tag_sanitize($profile_tab[4])] = $profile_tab[3];
    }
    add_action( 'bb_profile_menu', 'felavatartab' );

    OR

    function felavatartab()
    {
    add_profile_tab(__('Avatar'), 'edit_profile', 'moderate', 'avatar-upload.php');
    }
    add_action( 'bb_profile_menu', 'felavatartab' );

    I’ve got the file avatar-upload.php in my root directory, which loads the template avatar.php. If instead you give avatar.php as your argument the tab doesn’t show up at all.

    See it here. Any idea?


    Sam Bauers
    Participant

    @sambauers

    I tested the second method on the latest build and it passes the bb_repermalink tests and loads.

    I tried using standard URLs and both types of permalinks.

    I didn’t try to load a template. I used a file called avatar-upload.php containing the following:

    <?php
    require_once('./bb-load.php');

    bb_repermalink(); // The magic happens here.

    echo 'test';
    ?>

    My test plugin contained:

    <?php
    /*
    Plugin Name: Test for fel64
    Plugin URI:
    Description: Test profile tab addition
    Author: Scooby Doo
    Version: 0.0.1
    Author URI:
    */

    $bb->debug = 1;

    function felavatartab()
    {
    add_profile_tab(__('Avatar'), 'edit_profile', 'moderate', 'avatar-upload.php');
    }

    add_action( 'bb_profile_menu', 'felavatartab' );
    ?>

    Should really have been more familiar with the code – there’s a check to see if it’s the correct file, otherwise it simply redirects to the front page. Getting rid of that made it work.

    Thanks for all your help, Sam! :D


    LMD
    Participant

    @louisedade

    Aha! Thank you Sam! As fel has already discovered I abandoned any attempt at having “Upload Avatar” as a profile tab. It’s definitely going into the next version.

    Note that you will have to get rid of the filename check and that all that $user_id business is unnecessary and stopped my script executing. Just grab the global $user.

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