Skip to main content
The User model represents a user in the ForkBB forum system. It extends DataModel and provides properties and methods for managing user data, permissions, and profile information.

Location

app/Models/User/User.php

Properties

id
int
Unique user identifier
group_id
int
User’s group ID. Determines user role and permissions
username
string
User’s display name
email
string
User’s email address
title
string
Custom user title
signature
string
User’s signature displayed below posts
last_visit
int
Timestamp of last visit
avatar
string
Avatar file path or URL
language
string
User’s preferred language code
style
string
User’s preferred theme/style
disp_topics
int
Number of topics to display per page (minimum 10)
disp_posts
int
Number of posts to display per page (minimum 10)

Status Properties

isGuest
bool
Returns true if user is a guest (not authenticated)
isUnverified
bool
Returns true if user account is unverified
isAdmin
bool
Returns true if user is an administrator
isAdmMod
bool
Returns true if user is an administrator or moderator
isBanByName
bool
Returns true if user is banned by username
online
bool
Returns true if user is currently online
isSignature
bool
Returns true if user has a signature configured
usePM
bool
Returns true if user can use private messages

Methods

isModerator()

Checks if user is a moderator for a specific model.
public function isModerator(Model $model): bool
model
Model
The model (typically a Forum) to check moderator status for
Returns: bool - true if user moderates the given forum Example:
$user = $container->user;
$forum = $container->forums->get(5);

if ($user->isModerator($forum)) {
    // User can moderate this forum
}

deleteAvatar()

Deletes the user’s avatar file.
public function deleteAvatar(): void
Example:
$user = $container->users->load(123);
$user->deleteAvatar();

title()

Returns the user’s display title based on status and custom settings.
public function title(): string
Returns: User title (e.g., “Guest”, “Banned”, “Member”, custom title) Example:
$user = $container->user;
echo $user->title(); // "Administrator" or "Member" etc.

linkPromote()

Generates a link to promote a user based on a post they made.
public function linkPromote(Post $post): ?string
post
Post
The post to evaluate for user promotion
Returns: string|null - Promotion URL or null if not available Example:
$currentUser = $container->user;
$post = $container->posts->load(456);

$promoteLink = $currentUser->linkPromote($post);
if ($promoteLink) {
    echo "<a href=\"{$promoteLink}\">Promote User</a>";
}

fLog()

Returns formatted user information for logging purposes.
public function fLog(): string
Returns: Log-formatted string with user ID, group ID, and name Example:
$user = $container->user;
error_log('User action: ' . $user->fLog());
// Output: "User action: id:123 gid:1 name:john_doe"

Computed Properties

URL to user’s profile page. Returns null for guests.
avatar
string|null
Full URL to user’s avatar image. Returns null if no avatar.
currentVisit
int
Timestamp of current or last visit
htmlSign
string
HTML-formatted signature (parsed and censored)
email_normal
string
Normalized email address
username_normal
string
Normalized username
Link or mailto URL for contacting the user via email

Usage Example

// Get current user
$user = $container->user;

// Check permissions
if ($user->isAdmin) {
    // Admin-only actions
}

if ($user->isGuest) {
    // Redirect to login
}

// Get user information
echo "Welcome, {$user->username}!";
echo "Title: {$user->title()}";
echo "Profile: <a href=\"{$user->link}\">{$user->username}</a>";

// Check forum moderator status
$forum = $container->forums->get(10);
if ($user->isModerator($forum)) {
    // Show moderator tools
}

// Display avatar
if ($user->avatar) {
    echo "<img src=\"{$user->avatar}\" alt=\"Avatar\">";
}

Constants

The User model uses the following constants for group IDs:
  • FORK_GROUP_GUEST - Guest user group
  • FORK_GROUP_UNVERIFIED - Unverified user group
  • FORK_GROUP_ADMIN - Administrator group