Create a field group
6 min read
You need an administrator account (the manage_options capability) to create or change field groups.
The Field Groups list
Open WPM Fields › Field Groups (wp-admin/admin.php?page=wpmcf-field-groups).
Every field group is a card. A card shows:
Part | Meaning |
|---|---|
Title and description | What you entered in Group info. |
Healthy or No table badge | Whether the group's database table exists. No table means the definition is saved but its table is missing (see Table health). |
Updating or Changes failed badge | Shown while a large table is changed in the background, or when that change failed (see Changing a field group safely). |
PHP badge | The group is registered in code with |
Active / inactive badge | The group's Active setting (see Group settings). |
Column count and table name | For example |
Updated date | When the definition last changed. |
Edit and Delete | Open the editor, or delete the group. |
If a group has no table, an info box above the cards says how many groups have none. If the database contains wpmcf_fg_* tables that no group owns, a panel above the cards lists them as unregistered database tables (see Table health).
Add a field group
- Click Add field group. On a site with no groups yet, the same button is in the empty state.
- Under Group info enter:
Setting | Default | Effect |
|---|---|---|
Title (required) | empty | The name of the group. It is also the title of the box on edit screens. |
Key (required) | filled from the title | The identifier of the group. It follows the title as you type ( |
Description (optional) | empty | Shown to editors above the fields on edit screens, and on the card. |
The key must start with a letter and contain only lowercase letters, numbers and underscores (63 characters at most), and it must not be an SQL reserved word such as select, group or table, nor a plugin system word (id, mid, mtype, wpid, uid, created_at, updated_at, ai_context, omit_delivery). Typing a key with capitals or spaces through the REST API cleans it up (Bad Key becomes bad_key); the editor itself blocks invalid characters.
- Under Fields, add your fields. See Add and arrange fields.
- Under Settings › Location rules, say where the group appears. See Location rules. A group without rules is saved, but it is not shown anywhere.
- Optionally open Settings › Presentation to set the style, position and label placement. See Group settings.
- Click Create field group.
The plugin creates the database table, then stores the definition. You see the toast Field group "..." created. If the table cannot be created (for example the database user lacks the right to create tables), nothing is stored and the error says why.
What the editor shows
The editor has three collapsible sections. A new group starts with all of them open; a saved group shows a one-line summary for Group info and Settings.
Section | Contains |
|---|---|
Group info | Title, Key, Description, and for saved groups the Table health panel. |
Fields | The field builder with a counter such as |
Settings | Tabs Location rules, Presentation and (saved groups only) Group settings. The line |
Each section has a revert button (Revert all group info changes, Revert all field changes, Revert all settings changes) that goes back to the last saved state. If you leave with unsaved changes the editor asks before it closes.
For a saved group an extra Table differences panel appears between Group info and Fields when the table and the definition disagree.
Edit a field group
- Click the card or Edit. The address is
wp-admin/admin.php?page=wpmcf-field-groups#edit/{key}. - Change what you need and click Save changes.
What happens on save:
- The table is changed first (new columns, renamed columns, type changes, indexes). Only when that worked is the definition stored. If the database rejects the change, everything is rolled back and the message starts with the failing statement and ends with
Nothing was changed. - Warnings (for example "This group has 45 columns") are returned together with the saved group.
- If a removed field's name is reused by a new field, you are asked what to do with the old values. See Changing a field group safely.
- While a background change is still running, Save changes is disabled (and the REST API answers
409).
Click Cancel to go back to the list.
Groups registered in PHP
A group whose card shows PHP was registered by code (wpmcf_register_field_group(), see Developer API). The editor shows the note Registered in PHP and disables saving. Change the group in the code that registers it. Deleting it is also refused.
Delete a field group
You can delete from the card (Delete) or from the editor: Settings › Group settings › Delete field group....
- The dialog asks Delete field group? and names the table, for example
This deletes «Product details» and drops its database table «wpmcf_fg_product_details» with all stored values. - Optional: click Download the field group definition (JSON) first to keep a copy of the definition (the stored values are not part of that file).
- Click Delete.
The REST API refuses the request unless it carries confirm=true.
Create a group with the REST API
curl -X POST https://example.com/wp-json/wpmcf/v1/field-groups \
-H "Content-Type: application/json" -u admin:APP_PASSWORD \
-d '{
"key": "product_details",
"label": "Product details",
"location": [[{ "param": "post_type", "operator": "equal", "value": "product" }]],
"fields": [
{ "key": "price", "label": "Price", "type": "number" },
{ "key": "sku", "label": "SKU", "type": "text", "indexed": true }
]
}'Updates use PUT /wpmcf/v1/field-groups/{key}. A partial body keeps everything it leaves out. When you send fields back, keep each field's uid: the uid is how the plugin recognizes a field across saves, so a field sent with a new key and the same uid is a rename, while a missing uid is a new field.
Tips
- Plan the key and the field keys before you save: they become real column names.
- Prefer a few well named groups over one huge group. A table with fewer than about 40 columns stays easy to manage.
- Use Group fields for data you never filter by (for example an address block): it is one column instead of many.
- Back up the database before bigger structural changes.
Troubleshooting
Message | Cause and fix |
|---|---|
| Another group has this key. Choose another one. |
| The key is an SQL reserved word or a system column. Add a prefix such as |
| A table |
| Move related fields into a Group field. |
The save button is disabled | A background change is running, or the group is registered in PHP. |
Still stuck? Contact support