Skip to content

User Model ​

DB Table Name{wp_db_prefix}users (WordPress core)
SchemaCheck Schema
Source Filefluent-boards/app/Models/User.php
Name SpaceFluentBoards\App\Models
ClassFluentBoards\App\Models\User

A read model over the WordPress users table. The primary key is ID (uppercase). Use WordPress functions such as wp_insert_user() to create or change users; this model is for querying and relations.

Attributes ​

AttributeData TypeSerialized by toArray()?
IDBIGINT UNSIGNEDYes
user_loginVARCHAR(60)Yes
user_passVARCHAR(255)Never
user_nicenameVARCHAR(50)Never
user_emailVARCHAR(100)Only for privileged contexts (see below)
user_urlVARCHAR(100)Never
user_registeredDATETIMENever
user_activation_keyVARCHAR(255)Never
user_statusINTNever
display_nameVARCHAR(250)Yes

Appended attributes:

AttributeComment
photoAvatar URL from fluent_boards_user_avatar()

Hidden fields ​

The model always hides the fields listed in User::ALWAYS_HIDDEN (user_pass, user_activation_key, user_nicename, user_url, user_registered, user_status) when it is converted to an array or JSON.

user_email is listed in User::PRIVILEGED_ONLY. It is included only when the current user has the list_users capability, or when privileged serialization is turned on:

php
use FluentBoards\App\Models\User;

User::serializePrivilegedFields(true);
$data = $user->toArray(); // includes user_email
User::serializePrivilegedFields(false);

The hidden fields are still readable as properties ($user->user_email); hiding only affects serialization.

Usage ​

Please check Model Basic for common methods.

php
$user = FluentBoards\App\Models\User::find(1);

$user->ID;
$user->display_name;
$user->photo;

Relations ​

whichBoards ​

Boards the user is a member of (fbs_relations, object_type = 'board_user'). Pivot: settings, preferences.

  • Returns a collection of FluentBoards\App\Models\Board
php
// object_id on the board_user pivot row is the board ID
$boardIds = $user->whichBoards()->pluck('object_id')->toArray();

boards ​

WARNING

This relation joins fbs_relations.object_id to the user ID, but for board_user rows object_id is the board ID. It does not return the user's boards. Use whichBoards instead.

  • Returns a collection of FluentBoards\App\Models\Board

assignedTasks ​

Tasks assigned to the user (object_type = 'task_assignee'). Pivot: settings.

  • Returns a collection of FluentBoards\App\Models\Task
php
$open = $user->assignedTasks()->where('status', 'open')->whereNull('archived_at')->get();

watchingTasks ​

Tasks the user watches (object_type = 'task_user_watch'). Pivot: settings.

  • Returns a collection of FluentBoards\App\Models\Task

tasks ​

Same query as watchingTasks.

  • Returns a collection of FluentBoards\App\Models\Task

mentionedTasks() ​

Not a relation: a method that returns a Task query builder for tasks with a task_comment_mentioned notification sent to this user.

php
$mentioned = $user->mentionedTasks()->whereNull('archived_at')->get();

notifications ​

Notifications the user received (fbs_notification_users). Pivot: marked_read_at.

  • Returns a collection of FluentBoards\App\Models\Notification
php
$unread = $user->notifications()->wherePivot('marked_read_at', null)->count();

highPriorityTasks / overDueTasks / upcomingTasks / upcomingWithoutDuedate ​

WARNING

These relations filter on is_archived and due_date, which are not columns of fbs_tasks (the real columns are archived_at and due_at). Queries that use them fail. Build the query from watchingTasks() or assignedTasks() instead.

boardUser ​

Placeholder that returns null. Do not use.

Methods ​

User::serializePrivilegedFields($enabled = true) static ​

Turns inclusion of user_email in toArray() on or off for all User models.

getHidden() ​

Returns the hidden field list for the current context (always-hidden fields, plus user_email when not privileged).