Siren

Configuration

How get_option, update_option, and post meta translate to Siren's three-level config system.

WordPress plugin

Last updated: October 26, 2026

WordPress stores settings with get_option / update_option (global settings) and get_post_meta / update_post_meta (per-entity settings). Siren replaces both with a unified config system that uses a three-level hierarchy: type, subtype, and key.

The examples on this page use keys your extension defines, under its own type, myExtension. Siren keeps its own settings in the same table under types such as program, so an extension that writes to Siren’s types can overwrite Siren’s keys.

// WordPress: global settings
update_option('my_plugin_api_key', 'abc123');
$key = get_option('my_plugin_api_key');

// WordPress: per-entity settings
update_post_meta($post_id, '_commission_rate', '15');
$rate = get_post_meta($post_id, '_commission_rate', true);
// Siren facade: three-level config hierarchy
use Siren\Configs\Core\Facades\Configs;

// Read a config value: type, subtype, key, default
$rate = Configs::getConfigValue('myExtension', '42', 'maxCommission', '0');

// The facade only reads. To write a value, inject ConfigDatastore
// and call setConfig(), as the DI tab shows.
// Siren DI: inject ConfigDatastore
use Siren\Configs\Core\Datastores\Config\Interfaces\ConfigDatastore;

class CommissionService
{
    protected ConfigDatastore $config;

    public function __construct(ConfigDatastore $config)
    {
        $this->config = $config;
    }

    public function getMaxCommission(int $programId): string
    {
        return $this->config->getConfigValue(
            'myExtension',
            (string) $programId,
            'maxCommission',
            '0'   // default if not set
        );
    }

    public function setMaxCommission(int $programId, string $value): void
    {
        $this->config->setConfig(
            'myExtension',
            (string) $programId,
            'maxCommission',
            $value
        );
    }
}

How does the three-level hierarchy work?

Every config value is scoped by three coordinates:

  • type is the domain area. Siren’s own types include 'program', 'collaborator', and 'distributor'. Give your extension a type of its own, such as 'myExtension'.
  • subtype is the specific entity or context within that type. For entity-scoped settings, this is typically the entity’s ID as a string (e.g., '42'). For global settings within a domain, this might be a category name.
  • key is the individual setting name. Examples: 'maxCommission', 'payoutThreshold', 'notificationEmail'.

This maps cleanly to both of WordPress’s storage patterns. Global settings (get_option) correspond to a fixed type and subtype with varying keys. Per-entity settings (get_post_meta) correspond to a fixed type and key with varying subtypes (one per entity ID).

// Global setting: same type and subtype, different keys
$this->config->getConfigValue('myExtension', 'general', 'apiKey', '');
$this->config->getConfigValue('myExtension', 'general', 'notificationEmail', '');

// Per-program setting: same type and key, different subtypes (program IDs)
$this->config->getConfigValue('myExtension', '42', 'maxCommission', '0');
$this->config->getConfigValue('myExtension', '99', 'maxCommission', '0');

Why a single system instead of two?

WordPress’s split between wp_options and wp_postmeta creates a conceptual divide. Global settings live in one place, per-entity settings in another, and the APIs are different. Siren’s config system is one table, one API, one mental model. The scope is determined by the type/subtype/key coordinates, not by which function you call.

This also means config values are queryable the same way regardless of scope. You can fetch all config values for a given type and subtype, or all values with a given key across all subtypes.

Where can I learn more?

For the full ConfigDatastore API (querying, deleting, and batch operations), see the Configs resource reference.

For the full PHPNomad framework documentation on datastores, see Datastores Introduction.

Your privacy choices

Account, checkout and chat you request work without optional tracking. Choose whether to allow these other uses on this website.

You can change or withdraw your choices at any time using “Privacy choices.” We remember your choice for 180 days. Read our privacy policy.