@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix content: <http://purl.org/rss/1.0/modules/content/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://lhero.org/?post_type=lh-portfolio&#038;p=147130>
  a sioc:Post ;
  dc:title "Hooks and cron" ;
  dcterms:identifier 147130 ;
  dc:modified "2026-09-11T16:42:20Z"^^xsd:dateTime ;
  dc:created "2026-09-07T19:13:51Z"^^xsd:dateTime ;
  sioc:link <https://lhero.org/portfolio/lh-tasks/hooks-and-cron/> ;
  sioc:has_creator <https://lhero.org/author/1/#account> ;
  sioc:has_container <https://lhero.org/#posts> ;
  content:encoded """<ul class="lh_portfolio-meta"><li><strong>Type:</strong> Doc-section</li><li><strong>Part of:</strong> <a href="https://lhero.org/portfolio/lh-tasks/">LH Tasks</a></li></ul><table>
<thead>
<tr>
<th>Hook</th>
<th>Fired when</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>lh_tasks_task_created</code></td>
<td>After a task is created (<code>create_task()</code>)</td>
</tr>
<tr>
<td><code>lh_tasks_task_claimed</code></td>
<td>After a successful atomic claim</td>
</tr>
<tr>
<td><code>lh_tasks_task_completed</code></td>
<td>After <code>complete_task()</code></td>
</tr>
<tr>
<td><code>lh_tasks_task_failed</code></td>
<td>After <code>fail_task()</code> (includes <code>$reason_type</code> as its 5th argument)</td>
</tr>
<tr>
<td><code>lh_tasks_task_reassigned</code></td>
<td>After <code>reassign_task()</code> — args: <code>$post_id, $args, $from_status</code></td>
</tr>
<tr>
<td><code>lh_tasks_task_renewed</code></td>
<td>After <code>renew_task()</code> (the <code>renew-claim</code> heartbeat) — args: <code>$post_id, $note</code>. Added 1.7.0.</td>
</tr>
<tr>
<td><code>lh_tasks_task_admin_overridden</code></td>
<td>After <code>edit_task()</code> — args: <code>$post_id, $args, $from_status</code></td>
</tr>
<tr>
<td><code>lh_tasks_task_claim_expired</code></td>
<td>After the stale-claim sweep requeues an abandoned claim</td>
</tr>
<tr>
<td><code>lh_tasks_return_stale_claim_minutes</code> (filter)</td>
<td>Override the stale-claim timeout (default 10 minutes)</td>
</tr>
<tr>
<td><code>lh_tasks_return_required_capability</code> (filter)</td>
<td>Override the capability required to read/write tasks and MCP abilities (default <code>edit_others_posts</code>)</td>
</tr>
</tbody>
</table>
<p>Workflow status transitions (claim, complete, fail, reassign, renew, edit-task) write directly to the status table and fire their own <code>do_action()</code> calls — they no longer touch <code>wp_posts.post_status</code> at all, so <code>save_post_lh_tasks-task_post</code> will not fire for them. Code that needs to react to a claim, completion, failure, reassignment, renewal, or admin override should hook the corresponding <code>lh_tasks_task_*</code> action rather than <code>save_post</code>, which now only fires for genuine post edits (title/content/native status changes).</p>
<h2>Cron</h2>
<table>
<thead>
<tr>
<th>Hook</th>
<th>Schedule</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>lh_tasks_stale_claim_sweep</code></td>
<td>every 5 minutes (custom <code>lh_tasks_five_minutes</code> schedule)</td>
<td>Requeues tasks stuck in Claimed status longer than the stale-claim timeout (default 10 minutes) back to New. Only releases the claim (<code>assignee</code>) — <code>assigned_to</code>, if set, is untouched. A task can stay ahead of this sweep by calling <code>renew-claim</code> periodically (see MCP abilities), which pushes <code>claimed_at</code> forward and resets the window.</td>
</tr>
</tbody>
</table>
<p>Future-task activation (<code>scheduled_for</code>) is handled by WordPress&#8217;s own core <code>publish_future_post</code> cron; a <code>future_to_publish</code> intercept (added 1.6.0) lands it on <code>lh_tasks-active</code> rather than native <code>publish</code>.</p>
"""^^rdf:XMLLiteral ;
  sioc:content """Type: Doc-sectionPart of: LH Tasks


Hook
Fired when




lh_tasks_task_created
After a task is created (create_task())


lh_tasks_task_claimed
After a successful atomic claim


lh_tasks_task_completed
After complete_task()


lh_tasks_task_failed
After fail_task() (includes $reason_type as its 5th argument)


lh_tasks_task_reassigned
After reassign_task() — args: $post_id, $args, $from_status


lh_tasks_task_renewed
After renew_task() (the renew-claim heartbeat) — args: $post_id, $note. Added 1.7.0.


lh_tasks_task_admin_overridden
After edit_task() — args: $post_id, $args, $from_status


lh_tasks_task_claim_expired
After the stale-claim sweep requeues an abandoned claim


lh_tasks_return_stale_claim_minutes (filter)
Override the stale-claim timeout (default 10 minutes)


lh_tasks_return_required_capability (filter)
Override the capability required to read/write tasks and MCP abilities (default edit_others_posts)



Workflow status transitions (claim, complete, fail, reassign, renew, edit-task) write directly to the status table and fire their own do_action() calls — they no longer touch wp_posts.post_status at all, so save_post_lh_tasks-task_post will not fire for them. Code that needs to react to a claim, completion, failure, reassignment, renewal, or admin override should hook the corresponding lh_tasks_task_* action rather than save_post, which now only fires for genuine post edits (title/content/native status changes).
Cron



Hook
Schedule
Purpose




lh_tasks_stale_claim_sweep
every 5 minutes (custom lh_tasks_five_minutes schedule)
Requeues tasks stuck in Claimed status longer than the stale-claim timeout (default 10 minutes) back to New. Only releases the claim (assignee) — assigned_to, if set, is untouched. A task can stay ahead of this sweep by calling renew-claim periodically (see MCP abilities), which pushes claimed_at forward and resets the window.



Future-task activation (scheduled_for) is handled by WordPress&#8217;s own core publish_future_post cron; a future_to_publish intercept (added 1.6.0) lands it on lh_tasks-active rather than native publish.
""" ;
  sioc:topic <https://lhero.org/lh_portfolio-type/doc-section/>, <https://lhero.org/?taxonomy=author&term=cap-1> .

<https://lhero.org/author/1/#account> rdfs:seeAlso <https://lhero.org/author/1/?feed=lhrdf&format=turtle> .
<https://lhero.org/lh_portfolio-type/doc-section/> rdfs:seeAlso <https://lhero.org/lh_portfolio-type/doc-section/?feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=author&term=cap-1> rdfs:seeAlso <https://lhero.org/?taxonomy=author&term=cap-1&feed=lhrdf&format=turtle> .
