Skip to main content

mbr_math

Usage

This shortcode performs a calculation using the value stored in any contact field in your ActiveCampaign application. The result can be stored in any contact field in your ActiveCampaign application and also returned/displayed in WordPress.

Parameters

ParametersDescription
fieldThe name of an ActiveCampaign contact field to use as an operand. The field can be any contact field in ActiveCampaign. The available field names can be found in ActiveMember360, Utilities, Contact Fields. The lower case version of the Perstag should be used as the field name.
Default: none.
Required: yes.
contact_idThe ActiveCampaign contact ID of the contact for whom the shortcode should be executed.
Default: Current logged in user contact ID.
Required: no.
operationThe math operation to be performed.
Permitted Values: add, sub (subtract), div (divide), mul (multiply), pow (power), mod (modulus), sqr (square root), max (maximum), min (minimum).
Default: none.
Required: no.
valueThe second operand for the math operation to be performed. This can be any value including that stored in the specified contact field in ActiveCampaign. The available field names can be found in ActiveMember360, Utilities, Contact Fields. The lower case version of the Perstag should be used as the field name.
Default: none.
Required: yes, except for sqrt (square root)
targetThe name of an ActiveCampaign contact field in which to save the result. The field can be any contact field in ActiveCampaign. The available field names can be found in ActiveMember360, Utilities, Contact Fields. The lower case version of the Perstag should be used as the field name. If set to the special value 'noupdate' no result will be stored.
Default: field
Required: no.
roundThe decimal rounding to apply to the result. 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 e.g -1 round to nearest ten. Halves are always rounded up. 0 means any value will be rounded to an integer
Default: 0
Required: no.
flipSpecifies whether the order of the operands should be switched.
Permitted Values: 0, 1
Default: 0 (no)
Required: no.
showSpecifies if the result of the operation should be returned to WordPress for display or used within another shortcode.
Permitted Values: 0, 1
Default: 1 (yes)
Required: no.
formatA sprintf-type format string to apply to the result of the operation. The format must follow the syntax rules set for PHP as detailed within sprintf.
Example Values: %d formats as an integer, %.2f formats as a floating number with 2 decimal places.
Default: none.
Required: no.

Validity

This shortcode is only processed for logged in users who also exist as contacts within ActiveCampaign.

In all other cases, including WordPress users with the Administrator role nothing will be processed.

Conditional Branching

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

Nesting

Shortcode nesting within is NOT supported.

Examples

Returns the result of the calculation using the value stored in the field "fieldname1" with 300 added to it, storing the result back in the same field for the current logged in user:

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

API

info

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