Home / Archive / MemberPress: ActiveCampaign – Add Custom Field to ActiveCampaign Subscriber Data in MemberPress
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: ActiveCampaign – Add Custom Field to ActiveCampaign Subscriber Data in MemberPress

This code snippet customizes the data sent to ActiveCampaign through the MemberPress integration.

Once the code snippet is added to the website, the data sent to ActiveCampaign when a new subscriber is added through MemberPress, will also include the username in a specific custom field.

The sample code stores the username in the custom field with the ID of 350 in ActiveCampaign.

Code Preview
php
<?php
add_filter( 'mepr-activecampaign-add-subscriber-args', function( $args, $user ) {
  // Check if the username is set in the POST request and sanitize it
  $username = isset( $_POST['user_login'] ) ? sanitize_text_field( $_POST['user_login'] ) : '';
  // Add the username to the custom field (ID 350) in ActiveCampaign
  $args['field[350,0]'] = $username;
  return $args;
}, 10, 2 );

Comments

Add a Comment