Topic: [HOWTO] Add/Alter Profile Menu Options

If you are like me, you may have wanted to change the options on the left-hand side of profile.php - add additional options, remove options, whatever.  Currently, that is more or less hard-coded into PunBB.

There is an easy fix for this.

Step 1: Open up /include/functions.php

Around line 294 or so you should see:

function generate_profile_menu($page = '')

at the top of this function, add a variable similar to this:

$profile_spaces = array('essentials', 'personal', 'messaging', 'personality', 'display', 'privacy');

You'll want an entry for each left-hand side option you want exlcuding administration

You will then see you HTML, and a <ul> element with several hard-coded <li>'s that correspond to the entries you have on the left hand side.
If you didn't care, you could just add entries to this list, but my solution is a bit more dynamic and could eventually lead to a web based interface in which to add/remove profile menu options.

ahem.

You'll want to remove or comment everything between <ul> and </ul>

after the <ul>, you'll want to add the following:

<?php

foreach($profile_spaces as $space)
{ ?>
    <li<?php if ($page == $space) echo ' class="isactive"'; ?>><a href="profile.php?section=<? echo $space; ?>&id=<?php echo $id ?>"><?php echo $lang_profile['Section ' . $space] ?></a></li>
<? }

if ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '1')): ?><li<?php if ($page == 'admin') echo ' class="isactive"'; ?>><a href="profile.php?section=admin&id=<?php echo $id ?>"><?php echo $lang_profile['Section admin'] ?></a></li>
<?php endif; ?>

At this point, changes you make in the $profile_spaces will be reflected in the left hand side menu.

you will need to make the necessary adds to /lang/<language>/profile.php.

Also, you will need to make modifications to /profile.php:

around line ~1000, you will see:

else /* edit */
{
    if (!$section || $section == 'essentials')
    ...
    else if($section = 'personal')
    ...

Look at these if statements in order to determine what you'll need in order to make the profile menu item work.  At the very minimum, i find that each section should start from this:

    else if ($section == 'YOUR SECTION HERE')
    {

        if ($pun_user['g_set_title'] == '1')
            $title_field = '<label>'.$lang_common['Title'].'  (<em>'.$lang_profile['Leave blank'].'</em>)<br /><input type="text" name="title" value="'.pun_htmlspecialchars($user['title']).'" size="30" maxlength="50" /><br /></label>'."\n";

        $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
        require PUN_ROOT.'header.php';

        generate_profile_menu($section);

    ?>
        <div class="blockform">
            <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section media'] ?></span></h2>
            <div class="box">
                <form id="profile8" method="post" action="profile.php?section=<?php echo $section ?>&id=<?php echo $id ?>&action=foo">
                    <div class="inform">
                    <input type="hidden" name="form_sent" value="1" />
                    <fieldset>
                        YOUR FORM HERE
                    </fieldset>
                    </div>
                </form>
            </div>
        </div>
<?php
    }

around line ~650, you will see:

    // Validate input depending on section
    switch ($section)

there are a series of case statements - make sure to add a case statement for your new profile menu items.  this is for verifying the data you put into your form above.

eg:

case 'user data':
        {
                  BLAH BLAH BLAH
        }

There you have it.  eventually, i will post on how to create a web interface for adding/removing these elements and for editing the actual code that should go there.