Skip to main content

Set a Contact Field with JavaScript

Usage

ActiveMember360 provides a function that allows you to set a contact field for the contact associated with the current remote user.

The value specified always overwrites the existing field content. The function cannot be used to append data to a contact field.

The setting of any contact field is immediately effective within WordPress for the the current remote user.

Function

mbr_set_field ( $field, $value )

Parameters

ParametersTypeDescription
$field(string)Specifies the name of an ActiveCampaign contact field to set. The field can be any custom contact field in ActiveCampaign and any field type. The available field names can be found in ActiveMember360, Utilities, Contact Fields. The upper case version of the Perstag should be used as the field name.
Defaults: none.
Required: yes.
$value(string)Specifies the value for the ActiveCampaign contact field.
Defaults: none.
Required: yes.
Important

When setting multiple selection field types such as list box and checkbox the selections must be separated by a double pipe ||.

Examples

Using this Javascript code snippet in conjunction with a HTML button with the CSS class mbr-set-field-text, when the button is clicked the text field with the Perstag MY_TEXT will be set as Lorem lipsum for the remote user.

<script>
jQuery( document ).ready( function( $ ) {
$( '.mbr-set-field-text' ).click( function() {
mbr_set_field( 'MY_TEXT', 'Lorem lipsum');
} );
} );
</script>
<button class="mbr-set-field-text">
Set field named MY_TEXT (field type text) to Lorem lipsum
</button>