New to Pressable? Get 20% off your first year of annual Signature 1-4 plans with code YEAREND20. Shop Signature

Save Secrets as Encrypted Environment Variables

Last modified: December 2, 2026

Ask Your Favorite AI

Copy the link to a markdown format of this article for ChatGPT, Claude, Gemini, or your favorite AI.

Environment variables let you save secrets, such as API keys and passwords for outside services, in MyPressable instead of in your site’s files. Each value is encrypted as soon as you save it, and your theme or plugin code can read it with a short PHP snippet.

Without them, the usual options are hard-coding secrets in wp-config.php or building a small plugin to hold them. A single typo in wp-config.php can take your site offline, and anyone who can open the file can read what’s in it. Environment variables avoid both problems: you manage them from the dashboard, with no files to edit.

Before You Start

  • Permissions: collaborators need the Security permission on the site to see and manage environment variables. It isn’t one of the default collaborator permissions, so the account owner has to grant it. See adding a collaborator
  • Site status: the site must be active.
  • Code that reads the variable: saving a variable doesn’t change anything on its own. A variable is only used where your theme or plugin code reads it, as shown in Use a Variable in Your Code.

Add an Environment Variable

  1. Log in to MyPressable and select your site.
  2. Select Security, then scroll to the Variables card.
  3. Select Add variable.
  4. In Name, enter a name for the variable, such as STRIPE_SECRET_KEY.
  5. In Value, paste the secret.
  6. Select Save variable.

Your site can read the variable within a few seconds. Once saved, the value is hidden and can’t be viewed again, so if you might need it later, keep a copy somewhere safe, such as a password manager.

Variable names follow these rules:

  • Allowed characters: uppercase letters, numbers, and underscores. Names can’t start with a number.
  • Automatic formatting: lowercase letters are changed to uppercase, and spaces to underscores. For example, stripe secret key is saved as STRIPE_SECRET_KEY.
  • Length: names can be up to 255 characters, and values up to 45 KB.
  • Existing names: saving a name that already exists replaces that variable’s value.

Use a Variable in Your Code

Read a variable from your theme or plugin with the Atomic_Persistent_Data helper. Replace STRIPE_SECRET_KEY with your variable’s name:

$data = new Atomic_Persistent_Data();
$stripe_key = $data->STRIPE_SECRET_KEY;

MyPressable shows the same snippet under Using a variable in your code in the Variables card.

If a variable isn’t set on the site, the helper returns an empty value (null). Check for that before using it, so your code fails safely instead of sending an empty key to an outside service:

$data = new Atomic_Persistent_Data();
$api_key = $data->MY_API_KEY;

if ( empty( $api_key ) ) {
    // The variable isn't set on this site, so skip the request.
    return;
}

Keep secrets out of page output and logs. Printing a value with echo, print_r(), or var_dump(), or writing it to a debug log, exposes it to anyone who can see that page or file.

Update or Delete a Variable

To update a variable:

  1. In the Variables card, find the variable.
  2. Select Set new value.
  3. Enter the new value, then select Save.

The new value replaces the old one within a few seconds. The current value is never shown.

To delete a variable:

  1. In the Variables card, select the trash icon beside the variable.
  2. Select Delete variable to confirm.

Each variable shows when it was last updated and who updated it. Adding, updating, and deleting variables is also recorded in the site’s activity log.

How Your Values Are Protected

  • Encrypted at rest: each value is encrypted as soon as you save it.
  • Kept out of your site: values aren’t stored in your site’s files or WordPress database, so they don’t appear in wp-config.php, database exports, or file downloads.
  • Hidden in your dashboard: once you save a value, MyPressable never displays it again. You can replace or delete it, but not read it back.

Clones, Data Transfer, and Restores

Environment variables belong to the site they’re saved on. They don’t move with your site’s files and database:

  • Cloning a site: variables aren’t copied to the clone. Add them to the clone yourself.
  • Data Transfer: variables aren’t transferred. The destination site keeps its own variables, so add or update them there as needed.
  • Restoring a deleted site: values aren’t restored. On the restored site, select Set new value for each variable in the Variables card and enter it again. Add any variables that aren’t listed.
  • Restoring a backup: variables aren’t affected and keep their current values.

Because variables stay with each site, each environment can have its own values. For example, use a payment provider’s test key on a staging site and the live key on production.

Troubleshooting

  • Your code gets an empty value: check that the name in your code exactly matches the name in MyPressable, including uppercase letters and underscores. Then make sure the variable is saved on this site, since variables don’t carry over from clones, Data Transfer, or deleted-site restores.
  • “Key may only contain uppercase letters, numbers, and underscores, and cannot start with a number”: the name uses other characters, such as hyphens or periods, or starts with a number. Rename it to fit the naming rules above.
  • “Value is too large to set environment variable on site (maximum 45 KB)”: the value is over the size limit. Environment variables are meant for short secrets such as keys and passwords, not files.
  • You don’t see the Security page: your collaborator account doesn’t have the Security permission on this site. Ask the account owner to add it.