glFusion Wiki

Site Tools


glfusion:development:api:profile:start

User Profile Integration APIs

The glFusion user profile system consists of a set panels, broken down as follows:

  • Username & Password
  • About You
  • Layout & Language
  • Content
  • Privacy

Each panel contains a set of fields that the user may customize for their profile. The following profile APIs allow plugins to hook into these panels and add their own preference settings for the user.

PLG_profileEdit

(glFusion v1.1.5)

This API call a plugin's plugin_profileedit_<pluginname> function to allow the plugin to add items to the profile panels. This function is called for each fieldset on each panel. The plugin's function should check which panel and fieldset is being passed so they only add items to the areas they want.

Description

string PLG_profileEdit( $uid, $panel, $fieldset )

This would call a plugin's plugin_profileedit_<pluginname> function passing the following arguments:

Parameters

uid

The userid of the user being edited

panel

The panel name being displayed.

Panel names are:

  • namepass
  • userinfo
  • layout
  • content
  • privacy

A panel corresponds to the profile tab. Each panel consists of one or more fieldsets. The fieldset parameter is used to allow a plugin to add new fields to the existing fieldset. The function is also called with an empty fieldset value, which allows the plugin to insert their own complete fieldset on that panel.

fieldset

The current fieldset being displayed.

Fieldset names are:

  • namepass panel
    • name
    • pwdemail
  • userinfo panel
    • personalinfo
  • layout panel
    • display
    • comment
  • content panel
    • exclude
    • digest
    • boxes
  • privacy pane
    • privacy

Return Value

Returns the HTML to add to the profile panels.

Notes

The PLG_profileEdit() API will be called for each panel/fieldset combination, each panel, and one final time with no panel or fieldset. When called with no panel or fieldset, this gives the plugin the opportunity to add their own fieldset to the panel.

PLG_profileSave

(glFusion v1.1.5)

This function will call the plugin's plugin_profilesave_<pluginname> function. The plugin can then process their variables from the $_POST array.

Description

void PLG_profileSave( $plugin )

This would call a plugin's plugin_profilesave_<pluginname> function passing the following arguments:

Parameters

plugin

The name of a specific plugin or empty (all plugins).

Return Value

Void

Notes It will be up to the plugin's plugin_profilesave_<pluginname> function to retrieve the proper $_POST variables and process them.

Adding New Panels

It is also possible to add new panels (tabs) to the profile screen. The plugin can add an entry to the global $LANG_MYACCOUNT language array which will cause the new tab to appear in the profile tabs. When the PLG_profileEdit() function is called with an empty panel and empty fieldset, the plugin can return the full HTML for their own panel.

Examples This is an extreme example where each panel / fieldset is processed. Generally a plugin would only need to hook into one or two areas.

function plugin_profileedit_pm($uid,$panel,$fieldset)
{
    switch ($panel) {
        case 'namepass' :
            switch ($fieldset) {
                case 'name' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">PM FullName:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td></tr>';
                    break;
                case 'pwdemail' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">PM FullName:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td></tr>';
                    break;
                default :  // no fieldset passed, add a new one
                    $retval = '<fieldset style="margin-top:10px;"><legend>{lang_name_legend}</legend>
                        <table class="inputTable">
                            {username_option}
                            <tr>
                            <td style="width:150px;"><label for="fullname">{lang_fullname}:</label></td>
                            <td><input type="text" id="fullname" name="fullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td>
                        </tr>
                        {plugin_namepass_name}
                        </table>
                        </fieldset>';
                    break;
            }
            break;
        case 'userinfo' :
            switch ($fieldset) {
                case 'personalinfo' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">PM FullName:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td></tr>';
                    break;
                default :
                    $retval = '<fieldset><legend>Extra Fieldset</legend>stuff here</fieldset>';
                    break;
            }
            break;
        case 'layout' :
            switch ($fieldset) {
                case 'display' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">Display Setting:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="Some value here"{xhtml}></td></tr>';
                    break;
                case 'comment' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">PM FullName:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td></tr>';
                    break;
                default:
                    $retval = '<fieldset><legend>Extra Fieldset</legend>stuff here</fieldset>';
                    break;
            }
            break;
        case 'content' :
            switch ($fieldset) {
                case 'exclude' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">PM FullName:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td></tr>';
                    break;
                case 'digest' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">PM FullName:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td></tr>';
                    break;
                case 'boxes' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">PM FullName:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td></tr>';
                    break;
                default :
                    $retval = '<fieldset><legend>Extra Fieldset</legend>stuff here</fieldset>';
                    break;
            }
            break;
        case 'privacy' :
            switch ($fieldset) {
                case 'privacy' :
                    $retval = '<tr><td style="width:150px;"><label for="pmfullname">PM FullName:</label></td><td><input type="text" id="pmfullname" name="pmfullname" size="60" maxlength="80" value="{fullname_value}"{xhtml}></td></tr>';
                    break;
                default :
                    $retval = '<fieldset><legend>Extra Fieldset</legend>stuff here</fieldset>';
                    break;
            }
            break;

        default :
            $retval = '';
            break;
    }
    return $retval;
}
glfusion/development/api/profile/start.txt · Last modified: 2017/04/12 21:15 (external edit)

Page Tools