Add Calculation is a WordPress ability from Ninja Forms — usable via Easy MCP AI, which connects Claude, ChatGPT, and any AI assistant to your site.
Install Free Plugin →Add Calculation
WriteAdd a calculator formula to a form for use in calc fields and conditional logic.
Requires the Ninja Forms plugin on WordPress 6.9+ for the Abilities API (all 32 abilities are registered only when the wp_register_ability() function exists, via NF_Abilities_Integration::load_abilities_api() running on plugins_loaded). Every ability is gated by the same ninja_forms_ability_can_manage_forms() permission callback, requiring the caller to hold WordPress's manage_options capability or Ninja Forms' own nf_edit_forms capability.
What it does
This ability adds a named calculation to a form — a formula string referencing field values with {field:key} and other calculations with {calc:name}, combined with +, -, *, /, and parentheses — plus optional decimal formatting (decimal_places, decimal_point, thousands_sep). The result is displayed elsewhere on the form via an HTML field containing a spaced {calc:name} merge tag, or captured in a hidden field for the submission record. This lets an AI assistant build calculator/quote forms (price × quantity, tax totals, shipping estimates) from a plain-language description of the math involved.
See it in action
You ask your AI assistant
"Add a calculation to form 12 called 'total' that multiplies the Price field by the Quantity field, rounded to 2 decimal places."
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| form_id | integer | Yes | The numeric ID of the form. |
| name | string | Yes | Unique identifier for the calculation, referenced elsewhere as {calc:name}. |
| formula | string | Yes | Equation using {field:key} and {calc:name} references and +, -, *, /, (). |
| decimal_places | integer | No | Number of decimal places for the result. |
| decimal_point | string | No | Decimal point character. |
| thousands_sep | string | No | Thousands separator character. |
Returns
An object with a 'success' boolean, the 'form_id', the calculation 'name', a 'calculation' object, and a 'message'.
Permission
The current user must have WordPress's 'manage_options' capability or Ninja Forms' own 'nf_edit_forms' capability (checked via the shared ninja_forms_ability_can_manage_forms() permission callback).
More Ninja Forms abilities
Add Action
Add a post-submission action to a form — email, redirect, success message, or save.
Add Field
Add a single field to an existing form, to be called once per field when building out a form.
Create Form
Create a new Ninja Forms form, optionally with fields, actions, and calculations, in a single call.
Delete Action
Permanently delete an action from a form.
Delete Calculation
Permanently delete a calculation from a form.
Delete Form
Permanently delete a form and all of its fields, actions, and submissions.