๐ฅ User Model โ
The User model extends WordPress's user functionality for FluentBooking, providing additional methods and relationships specific to the booking system.
Attributes โ
As this model interacts with the WordPress users table, it includes standard WP_User fields plus FluentBooking specific logic.
| Attribute | Type | Description |
|---|---|---|
ID | int | Primary key (WordPress User ID) |
user_login | string | User login name |
display_name | string | User display name |
user_email | string | User email address |
created_at | datetime | Creation timestamp |
Usage โ
This model provides a fluent way to access booking-related data for any WordPress user.
Accessing Attributes โ
php
$user = \FluentBooking\App\Models\User::find(1);
echo $user->display_name;
echo $user->full_name; // Uses custom accessorMethods โ
getMeta($key, $default = null) โ
Retrieve a piece of metadata for the user.
updateMeta($key, $value) โ
Update or create a piece of user metadata.
isHost() โ
Check if the user has the necessary permissions to host calendars.
Relations โ
calendars โ
Has many Calendar records.
php
$calendars = $user->calendars;bookings โ
Belongs to many CalendarSlot records via fcal_booking_hosts pivot table (bookings where this user is assigned as a host).
php
$bookings = $user->bookings;Usage Examples โ
Retrieving Users with Data โ
php
use FluentBooking\App\Models\User;
// Get user with their calendars
$user = User::with('calendars')->find(1);
foreach ($user->calendars as $calendar) {
echo $calendar->title;
}Checking host status โ
php
$user = User::find($userId);
if ($user->isHost()) {
// Show hosting dashboard
}