Development Wiki

Difference between revisions of "User.setup"

From phpBB Development Wiki

(Fix little markup thingy)
(Example #2 Define additional language files)
Line 48: Line 48:
<php>// load mods/mylangfile.php AND search.php
<php>// load mods/mylangfile.php AND search.php
$user->setup(array('mods/mylangfile', 'search'));</php><br>
$user->setup(array('mods/mylangfile', 'search'));</php>
<php>// load mods/mylangfile.php language file board-wide in a shot..
// you'll simply use "user->setup()" there in the files where it is not defined, if needed.
// (suggested in the case your language file involves quite the entire board, IMHO)
// open includes/sessions.php
==See Also==
==See Also==

Revision as of 15:17, 25 September 2008

user::setup –– Setup basic user-specific settings - style and language.

This article is a stub. You can help in improving Olympus Documentation by expanding it.


  1. void setup ( [ mixed $lang_set [, int $style ]] )

Initialise user specific settings: common language file, date format, timezone, daylight savings time, optionally include additional language file(s), and optionally force a specific style for the page.


Parameter Usage
lang_set (optional) basename of language file(s) to include. Allows inclusion of a single language file or an array of language files.
style (optional) force (override style settings) a specific style by style_id. If not set, the style chosen by the user will be used or Board default style will be used by guests.

Return Values

This function always returns NULL


Example #1 A session setup example

In this example, we use the default language file (common.php) and for logged-in users, we use the style set in the user preferences, administrators can specify a &style=x URI param

// required to include function files
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH './';
$phpEx substr(strrchr(__FILE__'.'), 1);
$phpbb_root_path 'common.' $phpEx);

// Start session management

// Setup the auth/permissions for this user

// setup the user-specific settings, style and language

Example #2 Define additional language files

Additional language files can be loaded via the call to the $user->setup() method. To do so, pass the name with the subdirectory but without extension as argument of setup.

// load search.php language file
// load mods/mylangfile.php language file
// load mods/mylangfile.php AND search.php
// load mods/mylangfile.php language file board-wide in a shot..
// you'll simply use "user->setup()" there in the files where it is not defined, if needed.
// (suggested in the case your language file involves quite the entire board, IMHO)
// open includes/sessions.php

See Also