Skip to main content

REST API — Membership Tenure Badges

Two endpoints manage the site-wide tenure badge toggle. Both require the manage_options capability — WordPress administrator only.

Base URL: /wp-json/benecaster/v1/membership/tenure-badges


GET /benecaster/v1/membership/tenure-badges

Returns the current state of the tenure badge toggle.

Authentication: Cookie auth (nonce) or application password. Administrator only.

Request: No body or query parameters required.

Response — 200 OK:

{
  "enabled": false
}
Field Type Description
enabled boolean true when the tenure badge is active site-wide; false otherwise. A missing benecaster_tenure_badge_enabled option is treated as disabled

Error responses:

Status When
401 Unauthorized No valid authentication credentials
403 Forbidden Authenticated but caller lacks manage_options

POST /benecaster/v1/membership/tenure-badges

Updates the tenure badge toggle.

Authentication: Cookie auth (nonce) or application password. Administrator only.

Request body (application/json):

{
  "enabled": true
}
Field Type Required Description
enabled boolean Yes Pass true to enable the tenure badge site-wide; false to disable

Response — 200 OK:

{
  "enabled": true
}

The response echoes the new state. The underlying wp_option is set to '1' when enabled or '0' when disabled.

Error responses:

Status When
400 Bad Request enabled field is missing or not a boolean
401 Unauthorized No valid authentication credentials
403 Forbidden Authenticated but caller lacks manage_options

WordPress admin UI

The React settings screen at /#/memberships/badges (Benecaster → Settings → Memberships → Badges) is the standard way to toggle this setting. It reads and writes via these same endpoints. The outer container carries a data-tour="settings-membership-badges" attribute for future guided-tour targeting.

For scripted or programmatic changes — bulk site provisioning, WP-CLI wrappers, add-on activation hooks — calling the REST endpoint directly is the supported path.


See Also