1010 * Created on: 29/03/2023 (d/m/y)
1111 *
1212 * @link https://uriahsvictor.com
13- * @since 1.0.0
13+ * @since 1.0.1
1414 * @license GPLv2
1515 */
1616
@@ -53,12 +53,13 @@ function init(ServerRequestInterface $request): string
5353 $ custom_mappings = customContactDataMappings ();
5454 $ segments = contactSegments ();
5555 $ tags = contactTags ();
56+ $ excluded_emails = excludedEmails ();
5657
5758 $ contactCreate = new CreateContact ($ plugin_id );
5859 $ id = $ contactCreate ->setCustomMappings ($ custom_mappings )
5960 ->setSegments ($ segments )
6061 ->setTags ($ tags )
61- ->add ($ user_data );
62+ ->add ($ user_data, $ excluded_emails );
6263
6364 break ;
6465 case 'install.deactivated ' :
@@ -68,8 +69,14 @@ function init(ServerRequestInterface $request): string
6869 break ;
6970 }
7071
71- // In production you might probably just want to send back an empty string...
72- return ($ id ) ?: "The username and password set for the Client is probably wrong. Or the URL you set for the Mautic API is wrong. " ;
72+ /**
73+ * This will return null if:
74+ *
75+ * The username and password set for the Client is wrong.
76+ * The URL you set for the Mautic API is wrong.
77+ * The contact email is in the excluded list.
78+ */
79+ return json_encode ($ id );
7380}
7481
7582// ------
@@ -100,7 +107,7 @@ function customContactDataMappings(): array
100107 '11538 ' => array ( // Add other plugins you own.
101108 'id ' => 'freemius_id ' ,
102109 'gross ' => 'dps_gross ' ,
103- )
110+ ),
104111 // You can add further plugin IDs and their mappings.
105112 );
106113
@@ -125,7 +132,8 @@ function contactSegments(): array
125132 ),
126133 '11538 ' => array ( // Add other plugins you own.
127134 3
128- )
135+ ),
136+ // You can add further plugin IDs and their mappings.
129137 );
130138
131139}
@@ -156,7 +164,20 @@ function contactTags(): array
156164 'dps-pro-user '
157165 ),
158166 'dps-user '
159- )
167+ ),
168+ // You can add further plugin IDs and their mappings.
169+ );
170+ }
171+
172+ /**
173+ * Email addresses that should be excluded from being added to mautic.
174+ *
175+ * @return array
176+ * @since 1.0.1
177+ */
178+ function excludedEmails (): array
179+ {
180+ return array (
160181 );
161182}
162183
0 commit comments