Skip to content
WP EngineDocumentation

Embargoed Content

Embargoed Content attempts to prevent embargoed posts from being published, exposed via queries, or read by unauthorized users until the embargo lifts. It does this through two layers: publishing guards (which try to prevent invalid states) and display and capability guards (which try to hide embargoed content from queries and capability checks). All of these protections are best-effort attempts rather than guarantees: themes, plugins, custom code, caching, other WordPress behavior, and direct database access may bypass them.

Access is decided in two stages. A bypass skips the guards entirely (for every embargoed post); a per-post exemption lifts only the one post that carries the granting meta. Anonymous visitors (logged out, user ID 0) are never exempt: neither a bypass nor a per-post exemption applies to them.

Bypass — Helpers::can_user_bypass_guards() (skips the display and capability guards for all embargoed posts):

  • User’s ID is in the site-wide allowed-users setting (mediapress_embargoed_content_settings_allowed_users).
  • User holds a role in the site-wide allowed-roles setting (mediapress_embargoed_content_settings_allowed_roles).

Per-post exemption — Helpers::is_post_viewable_by_user() (applies to the single embargoed post carrying the meta):

  • Post author — the user authored the post.
  • Allowed users — the user’s ID is in the post’s allowed_users meta.
  • Allowed roles — the user holds a role in the post’s allowed_roles meta.
  • Allow everyone — the post’s allowed_all toggle is enabled (grants any logged-in user whose role can edit others’ posts, editors and administrators by default; anonymous visitors remain embargoed).

Publishing guards apply to every user, whatever their capability, bypass, or exemption.

  • Date — the post is embargoed until its UTC lift date (mediapress_embargoed_content_lift_date_utc) passes, after which the guards step aside.
  • Indefinitely — setting mediapress_embargoed_content_is_indefinitely to true restricts the post with no expiry. It is blocked from being published, scheduled, or made private, and is hidden from users without access where the display and capability guards apply, until the flag is cleared.

Embargoed attachments are flagged with a lock badge in the MediaPress media UI — on grid items, list items, and in the media info panel. This is a visual cue only; access is enforced by the display and capability guards.

The badge is registered by consuming two JavaScript extension points exposed by the core media package (documented under Filters/Actions → JavaScript → Filters in the Media docs):

  • mediaPress.media.mediaItem — HOC wrapping each grid/list item; reads mediaItem from props.
  • mediaPress.media.mediaInfo — HOC wrapping the info panel; the record isn’t passed as a prop, so the callback re-fetches it with useEntityRecord using the attachmentId prop (core-data caches it, so no extra request).

Both callbacks render the badge when the attachment’s mediapress_embargoed_content_is_embargoed field (returned in edit context) is true. The badge component and all positioning styles live in Embargoed Content — the Media package references the badge nowhere, keeping the dependency direction one-way (Embargoed Content → Media).

When an embargoed post is trashed, restored, or permanently deleted, the package propagates that operation to all attachments whose post_parent is the affected post. This keeps media consistent with its parent and prevents orphaned files from lingering after the parent is removed.

Action on embargoed post Effect on attachments WordPress action hook Condition
Trashed Attachments are moved to trash trashed_post EMPTY_TRASH_DAYS and MEDIA_TRASH are set
Restored from trash Trashed attachments are restored untrashed_post EMPTY_TRASH_DAYS and MEDIA_TRASH are set
Permanently deleted Attachments are permanently deleted before_delete_post Always

Maps each post type slug to the embargo supports it declares.

Default

[
'post' => [ 'self' ],
'page' => [ 'self' ],
]

Supported values for the supports array:

  • 'self' — the post type carries its own embargo meta.
  • 'parent' — the post type inherits its embargo from its post_parent (most-restrictive wins). Only the direct post parent is checked; parent types are not resolved recursively through other parent types.

Usage

add_filter( 'mediapress_embargoed_content_post_types', function ( $post_types ) {
$post_types['mediapress_custom_post_type'] = [ 'self' ];
return $post_types;
});

The revision and attachment post types are always appended as [ 'parent' ] after the filter runs and cannot be removed or overridden. They carry no embargo meta of their own; their embargoed state is inherited entirely from their parent post.

Publishing guards block attempts to publish or make private embargoed posts, to schedule them to publish before the embargo lifts, or to write contradictory embargo metadata. They aim to cover as much of the standard publishing surface as possible: block editor, quick edit, REST API, WP-CLI, programmatic calls, and cron.

wp_insert_post() /wp_update_post()REST POST / PUT/wp/v2/postswp_publish_post()WP-Cron publishing ascheduled postupdate_post_meta() /add_post_meta()YesNoYesNoYesNoYesNoYesNoPublish / update attemptEntry pointwp_insert_post_datarest_pre_insert_{post_type}transition_post_statuspublish_future_postupdate_post_metadata/add_post_metadataResulting statuspublish, future, orprivate,and embargo conflicts?Resulting statuspublish, future, orprivate,and embargo conflicts?Currently embargoedand old status != publish?Currently embargoed?Meta change createscontradictory state?Downgrade to previousstatusor draft if it waspublish / future /privateAllowReturn WP_Error — blockrequestRevert to previous statusvia wp_update_postMove to draft beforecore publishes itReturn false — block metawrite

Display and capability guards attempt to hide embargoed content from queries and block unauthorized access via capability checks. Queries from logged-in admin and REST requests are filtered via pre_get_posts, other queries according to the query guard setting, and frontend singular views via template_redirect when the single post view guard is on.

WP_Query (admin / logged-inREST,others per setting)user_can /current_user_canSingular frontend view(when enabled)YesYesNoYesNoNoYesNoNoYesNoYesYesNoYesNoRead attemptEntry pointpre_get_postsmap_meta_captemplate_redirectAll queried typesare parent-only?(attachment, revision)Query haspost_parent?Set post__into [0]Query haspost_parent__in?Diff hidden parent IDsout of post_parent__in([0] sentinel if empty)Append hidden parent IDstopost_parent__not_inQuery has post__in?Diff embargoed IDs out ofpost__in([0] sentinel if empty)Append embargoed IDsto post__not_incap inread_post / edit_post /delete_post /read_page / edit_page /delete_page?Pass through unchangedPost embargoed?Viewable by user?author, allowed_users,allowed_roles, orallowed_allanonymous always deniedGrant capabilityReturn['do_not_allow']Embargoed andnot viewable by user?404 + exitAllow

Admin and REST requests from a logged-in user, such as admin screens, the media modal, and the block editor, are guarded in every mode. Other queries for post types that use embargoes are guarded according to MediaPress → Settings → Embargoed Content → Query guard. Every mode other than Off adds work to these requests; the performance cost depends on your site, so performance testing on a staging site is advisable before enabling one on a live site.

Mode Queries guarded Statuses guarded Performance cost
Off (default) None None -
Light Main query only Non-public Unknown
Moderate Main and secondary Non-public Unknown; higher than Light
Strict All All Unknown; higher than Moderate

A query counts as non-public when it explicitly requests a status such as draft, inherit, or any (for example get_children(), gallery and attachment queries).

Light checks only the page’s main query, so it skips secondary queries such as widgets, related posts, and galleries, and does not apply to requests with no main query (logged-out admin-ajax.php, admin-post.php, REST, WP-CLI, and cron). Strict also covers published content, so it attempts to hide a post that ends up published despite the publishing guards.

Capabilities are checked by map_meta_cap in every mode.

MediaPress → Settings → Embargoed Content → Single post view guard (off by default) hooks template_redirect and attempts to return a 404 when a user who can’t view an embargoed post opens it on the frontend, including a published post still carrying an active embargo, in case one ends up published despite the publishing guards. It adds a small amount of work to single post views of post types that use embargoes; the performance cost is unknown and varies by site.

Entry point Guard Result when blocked
wp_insert_post(), wp_update_post() wp_insert_post_data Status forced to draft / previous
REST POST /wp/v2/posts[/{id}] rest_pre_insert_{post_type} 400 WP_Error
wp_publish_post() transition_post_status Reverted via wp_update_post
WP-Cron publishing a scheduled post publish_future_post Moved to draft before publishing
update_post_meta() / add_post_meta() on embargoed keys update_post_metadata / add_post_metadata Returns false, meta unchanged
WP_Query, logged-in admin and REST pre_get_posts Embargoed IDs excluded
WP_Query, everything else pre_get_posts, per the query guard mode Embargoed IDs excluded
Singular frontend view template_redirect, if the setting is on 404 + exit
user_can( 'read_post' / 'edit_post' / 'delete_post' / 'read_page' / 'edit_page' / 'delete_page' ) map_meta_cap do_not_allow

Last updated: