Contents

Writers

Several things save rows: an open tab checking in, a page loading, someone logging in, an AI agent saving a post. Each keeps its own rows alive by saving them again.

How it works #

What writes and removes rowsPage loads, Heartbeat ticks, login, post locks, agent saves, push transports and WP-CLI write rows to wp_presence. Logout and leaving a page remove them.write and renewremoved by

Page loads
Heartbeat ticks
logins, post locks
agent saves, push transports

wp_presence

Logout or
leaving a page

Writer Rows
Page load user-{id}, and editor-{id} on a post's edit screen
Heartbeat tick The same rows, renewed
Login user-{id}, with the screen login
Post lock _lock in the post room
Agent save agent-{id} in the post room
Push transport user-{id} and editor-{id}, in place of Heartbeat
WP-CLI Any row, cli-{id} by default

Rows are also removed when a tab leaves its page, when the user is deleted, and when the user logs out, which keeps only _lock.

A write that changes nothing is skipped while the row was stamped within the last 30 seconds, so frequent ticks do not rewrite an unchanged row.

Source: heartbeat.php · lifecycle.php · presence-ping.js

Check your understanding #

Which rows does logging out remove, and which does it keep?

It removes every row the user wrote except _lock, so a post lock outlasts the logout.

Edit this page on GitHub