# mbr_math

## Overview

**ActiveMember360 mbr_math** is used to perform a calculation using the value from and storing the result to any contact field in your ActiveCampaign application.

## Usage

The URL used for the mbr_math webhook is constructed using your site URL and parameters.

A sample of the URL structure required is as follows:

`site_url/?mbr_math=my_security_code`

The mbr_math URL is used as the webhook URL in an ActiveCampaign automation.

## Site URL & Parameters

Site URL | Description |
---|---|

site_url | The WordPress site URL from which the WordPress user is to be deleted. This can be found in WordPress, Settings, General, Site URL. It must be specified exactly as shown there.Default: none.Required: yes. |

## Parameters

Parameters | Description | |
---|---|---|

mbr_math | Set to the security code used to authenticate the use of mbr_math. The security code used must be defined as detailed in ActiveMember360, Settings, Security, Security Codes.Default: none.Required: yes. | |

field | The 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][utilities-contact-fields]. The lower case version of the Perstag should be used as the field name.Defaults: none.Required: no. | Required: yes. |

operation | The 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. | |

value | The 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][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) | |

target | The 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][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. | |

round | The 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 integerDefault: 0Required: no. | |

decimal | The number of decimals places used to store the result into ActiveCampaign. If a value of 0 is specified, which is the default, the value will be stored as an integer.Default: 0 Required: no. |

## Examples

##### Important

In all examples **my_security_code** must be replaced by a security code defined in **ActiveMember360, Settings, Security, Security Codes** on the WordPress site.

- Example 1
- Example 2
- Example 3
- Example 4

This webhook URL will take the value stored in the field "fieldname1", add 300 to it, and store the result back into the same field as an integer:

`https://yoursite.com/?mbr_math=my_security_code&field=fieldname1&operation=add&value=300`

This webhook URL will perform a calculation using the value stored in the field "fieldname1" divided by 2, storing the result back in the same field as an integer:

`https://yoursite.com/?mbr_math=my_security_code&field=fieldname1&operation=divide&value=2`

This webhook URL will perform a calculation using the value stored in the field "fieldname1" multiplied by 39.95. The result is rounded to two decimal places and stored as a floating number with 2 decimal places in the field "fieldname2":

`https://yoursite.com/?mbr_math=my_security_code&field=fieldname1&operation=multiply&value=39.95&round=2&decimals=2&target=fieldname2`

This webhook URL will perform a calculation using the value stored in the field "fieldname1" adding the value stored in the field "fieldname2". The result is rounded to two decimal places and stored as a floating number with 2 decimal places in the field "fieldname3":

`https://yoursite.com/?mbr_math=my_security_code&field=fieldname1&operation=add&value=fieldname2&target=fieldname3&round=2&decimal=2`