---
title: Embargoed Content
description: Embargoed Content attempts to keep embargoed posts unpublished, out of queries, and unreadable by unauthorized users until the embargo lifts.
url: https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/
image: https://developers.wpengine.com/og/docs/newsroom/mediapress/embargoed-content.png
---

# 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.

## Who can view embargoed content

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.

## How an embargo is defined

- **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 media indicator

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](https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/#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](https://developers.wpengine.com/docs/newsroom/mediapress/media/)):

- `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).

## Media lifecycle

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                                       |

> **Caution**
>
> Any plugin registering a `parent`-inheriting type via `mediapress_embargoed_content_post_types` must satisfy two conditions for attachment cleanup to work correctly:
>
> 1. Any hook that triggers or performs post deletion must run on `before_delete_post` or earlier, so the parent post still exists in the database when the package resolves its type and embargo state.
> 2. The function used to delete the post must itself fire `before_delete_post`.
>
> If either condition is not met, `get_post_type()` returns `false`, `is_post_embargoed()` cannot resolve the post, and attachment cleanup is silently skipped.

## Hooks

### `mediapress_embargoed_content_post_types`

> **Caution**
>
> This filter is for MediaPress internal use only and may change without notice.

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

**Default**

```php
[
  '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.

> **Caution**
>
> Two configurations are experimental and may not function as expected: setting both `self` and `parent` on the same post type, and using custom post types that have their own capabilities with `map_meta_cap` set to `false`.

**Usage**

```php
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.

> **Attachment file access**
>
> Attachments inherit embargo checks from their parent post, which blocks access via the Media Library, REST API, and `wp_ajax_get-attachment`. This does **not** prevent direct file access via URL: an unauthorized user who knows or guesses the file URL (`/wp-content/uploads/...`) can access the file directly.
>
> To make guessing harder, filenames are obfuscated for files uploaded while the package is active. Directory indexing **must** be disabled in your server configuration.

## Publishing guards

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.

> **Note**
>
> The meta hook is the backstop: even if a future-extended embargo date *did* reach `wp_postmeta` directly (for example, through `$wpdb->update()`), the publish-side hooks would still catch the next publish attempt.

## Display and capability guards

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](https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/#query-guard-setting) setting, and frontend singular views via `template_redirect` when the [single post view guard](https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/#single-post-view-guard-setting) is on.

### Query guard setting

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.

### Single post view guard setting

**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.

## Coverage matrix

> **Caution**
>
> The guards cover the entry points below. Other data access paths, such as direct `$wpdb` queries, `get_post()`, XML-RPC, and queries outside the selected [query guard](https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/#query-guard-setting) mode, are not intercepted. XML-RPC should be disabled on sites that use embargoes.

| 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`                    |

## Was this helpful?

Thanks for the feedback!

```json
{"@context":"https://schema.org","@graph":[{"@type":"WebSite","@id":"https://developers.wpengine.com/#website","name":"WP Engine Product Documentation","url":"https://developers.wpengine.com/","description":"Resources for developing, deploying, and scaling on WP Engine.","inLanguage":"en-US","keywords":["API documentation","product documentation","headless WordPress","managed WordPress hosting"],"publisher":{"@id":"https://wpengine.com/#organization"}},{"@type":"Organization","@id":"https://wpengine.com/#organization","name":"WP Engine","url":"https://wpengine.com/"},{"@type":"TechArticle","@id":"https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/#article","mainEntityOfPage":{"@type":"WebPage","@id":"https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/"},"headline":"Embargoed Content","description":"Embargoed Content attempts to keep embargoed posts unpublished, out of queries, and unreadable by unauthorized users until the embargo lifts.","image":"https://developers.wpengine.com/og/docs/newsroom/mediapress/embargoed-content.png","author":{"@id":"https://wpengine.com/#organization"},"publisher":{"@id":"https://wpengine.com/#organization"},"dateModified":"2026-11-25T00:00:00.000Z","inLanguage":"en-US","isPartOf":{"@id":"https://developers.wpengine.com/#website"}},{"@type":"BreadcrumbList","@id":"https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"WP Engine Product Documentation","item":"https://developers.wpengine.com/"},{"@type":"ListItem","position":2,"name":"Newsroom","item":"https://developers.wpengine.com/docs/newsroom/"},{"@type":"ListItem","position":3,"name":"Embargoed Content","item":"https://developers.wpengine.com/docs/newsroom/mediapress/embargoed-content/"}]}]}
```
