Development Wiki

Difference between revisions of "User.setup"

From phpBB Development Wiki

(Category User (class))
(Category User (class))
Line 69: Line 69:

Latest revision as of 00:46, 28 March 2009

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
// trick/tip
// 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