Skip to content

Commit fd8c1f0

Browse files
committed
Add ach_tags
1 parent 558fcbb commit fd8c1f0

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ function change_list_id( $preset_list_id ) {
7272
add_filter( 'ach_list', 'change_list_id', 10, 1 );
7373
```
7474

75+
# ach_tags
76+
77+
This filter can be used to add tags before subscribe. Create a custom function to return an array of tags such as:
78+
79+
```
80+
function add_tags_id() {
81+
return array('foo', 'bar');
82+
}
83+
add_filter( 'ach_tags', 'add_tags', 10, 0 );
84+
```
85+
7586
## Using the JavaScript functions
7687

7788
The plugin offers 3 convenience functions.
@@ -194,3 +205,7 @@ Integrate ACs new tracking code.
194205
#### 0.0.12
195206

196207
- Add ach_list filter to dynamicallyt modify list ID before subscribe
208+
209+
#### 0.0.13
210+
211+
- Add ach_tags filter to dynamicallyt add tags before subscribe

activecampaign-helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Description: Provide easy subscribe options in checkout and registration and add email tracking ability. To get started active the plugin and edit your <a href="options-general.php?page=ach_settings">settings</a>.
55
* Author: Enradia
66
* Author URI: https://github.com/cyberwombat/activecampaign-helper
7-
* Version: 0.0.12
7+
* Version: 0.0.13
88
* Requires at least: 4.4
99
* Tested up to: 4.9.6
1010
* WC requires at least: 3.0

includes/class-ac-helper-api.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,20 @@ public function subscribe_to_list($email, $fields = array())
4040
$list = get_option('ac_helper_list_id');
4141

4242
$list = apply_filters('ach_list', $list);
43+
$tags = apply_filters('ach_tags');
4344

4445
if (!$list || !is_numeric($list)) {
4546
AC_Helper::log('Subscription failed - No valid AC list ID provided');
4647
return array('success' => false, 'error' => 'No valid AC list ID provided');
4748
}
4849

49-
5050
$params = array(
5151
'email' => $email,
52-
'p['.$list.']' => $list,
53-
'status['.$list.']]' => 1
52+
'p['.$list.']' => $list,
53+
'status['.$list.']]' => 1,
54+
'tags' => is_array($tags) ? implode(',', $tags) : ''
5455
);
56+
5557
$res = $this->do_api_call('contact_sync', array_merge($params, $fields));
5658
AC_Helper::log($email . ' subscribed to list '.$list .' - '.($res->success ? 'success!' : 'failed! ' .$res->response->result_message));
5759

0 commit comments

Comments
 (0)