Usage:

This shortcode is designed to allow you to query a contact field in your ActiveCampaign application, perform a simple math operation on it, display/use it, and optionally store the result in ActiveCampaign.

This shortcode does NOT support conditional branching with [ELSE_math].

Shortcode nesting is NOT supported.

Parameters:

fieldThe name of the field to query.
Required: Yes.
Default: none.
operationSpecifies the math operation to be performed. Valid operations are:
add, sub (subtract), div (divide), mul (multiply), pow (power), mod (modulus), sqr (square root), max (maximum), min (minimum).
valueThe second operand in the operation to be performed.
Required: Yes, except for sqrt (square root)
Default: none.
targetfield where the result should be stored back.
Required: No.
Default: “field”
roundThe number of decimal digits to round the result of the operation to. If a positive value is provided the rounding will occur after the decimal point, if a negative value is provided the rounding will occur before the decimal point. Halves are always rounded up. 0 means any value will be rounded to an integer
Required: No.
Default: none.
flipSpecifies whether the order of the operands should be switched.
Required: No.
Default: 0 (no).
showSpecifies if the result of the operation should be returned to WordPress for display or further use within another shortcode.
Required: No.
Default: 1 (yes).
formatProvides a sprintf-type format string to apply to the result of the operation.
Example Values: %d formats as an integer.
%.2f formats as a floating number with 2 decimal places.
Required: No.
Default: none.

Example:

1. The value of the field “fieldname1” will be queried and 300 will be added to it, storing the result back in the same field. The “show” option indicates that the result of the operation should be returned/displayed.

[mbr_math field='fieldname1' operation='add' value='300' show='1']

2. The value of the field “fieldname1” will be queried and divided by 2, storing the result back in the same field. The “show” option indicates that the result of the operation should NOT be returned/displayed.

[mbr_math field='fieldname1' operation='divide' value='2' show='0']

3. The value of the field “fieldname1” will be queried and the value of “fieldname2” will be added to it, the result will be rounded to two decimal places and stored as a floating number with 2 decimal places back in the same field. The ‘show’ option indicates that the result of the operation should NOT be returned/displayed

[mbr_math field='fieldname1' operation='add' value='fieldname2' target='fieldname3' show='0' round='2' format='%.2f']

API:

There is currently no ActiveMember360 API function equivalent for this shortcode.