@@ -222,21 +222,63 @@ public function get_landing_pages(
222
222
);
223
223
}
224
224
225
+ /**
226
+ * Adds subscribers to forms in bulk.
227
+ *
228
+ * @param array<array<string,int>> $forms_subscribers_ids Array of arrays comprising of `form_id` and `subscriber_id`.
229
+ * @param string $referrer Referrer URL.
230
+ * @param string $callback_url URL to notify for large batch size when async processing complete.
231
+ *
232
+ * @since 2.1.0
233
+ *
234
+ * @see https://developers.kit.com/v4.html#bulk-add-subscribers-to-forms
235
+ *
236
+ * @return false|object
237
+ */
238
+ public function add_subscribers_to_forms (array $ forms_subscribers_ids , string $ referrer = '' , string $ callback_url = '' )
239
+ {
240
+ // Build parameters.
241
+ $ options = [
242
+ 'additions ' => $ forms_subscribers_ids ,
243
+ ];
244
+ if (!empty ($ referrer )) {
245
+ $ options ['referrer ' ] = $ referrer ;
246
+ }
247
+ if (!empty ($ callback_url )) {
248
+ $ options ['callback_url ' ] = $ callback_url ;
249
+ }
250
+
251
+ // Send request.
252
+ return $ this ->post (
253
+ 'bulk/forms/subscribers ' ,
254
+ $ options
255
+ );
256
+ }
257
+
225
258
/**
226
259
* Adds a subscriber to a form by email address
227
260
*
228
261
* @param integer $form_id Form ID.
229
262
* @param string $email_address Email Address.
263
+ * @param string $referrer Referrer.
230
264
*
231
265
* @see https://developers.convertkit.com/v4.html#add-subscriber-to-form-by-email-address
232
266
*
233
267
* @return false|mixed
234
268
*/
235
- public function add_subscriber_to_form_by_email (int $ form_id , string $ email_address )
269
+ public function add_subscriber_to_form_by_email (int $ form_id , string $ email_address, string $ referrer = '' )
236
270
{
271
+ // Build parameters.
272
+ $ options = ['email_address ' => $ email_address ];
273
+
274
+ if (!empty ($ referrer )) {
275
+ $ options ['referrer ' ] = $ referrer ;
276
+ }
277
+
278
+ // Send request.
237
279
return $ this ->post (
238
280
sprintf ('forms/%s/subscribers ' , $ form_id ),
239
- [ ' email_address ' => $ email_address ]
281
+ $ options
240
282
);
241
283
}
242
284
@@ -245,16 +287,28 @@ public function add_subscriber_to_form_by_email(int $form_id, string $email_addr
245
287
*
246
288
* @param integer $form_id Form ID.
247
289
* @param integer $subscriber_id Subscriber ID.
290
+ * @param string $referrer Referrer URL.
248
291
*
249
292
* @see https://developers.convertkit.com/v4.html#add-subscriber-to-form
250
293
*
251
294
* @since 2.0.0
252
295
*
253
296
* @return false|mixed
254
297
*/
255
- public function add_subscriber_to_form (int $ form_id , int $ subscriber_id )
298
+ public function add_subscriber_to_form (int $ form_id , int $ subscriber_id, string $ referrer = '' )
256
299
{
257
- return $ this ->post (sprintf ('forms/%s/subscribers/%s ' , $ form_id , $ subscriber_id ));
300
+ // Build parameters.
301
+ $ options = [];
302
+
303
+ if (!empty ($ referrer )) {
304
+ $ options ['referrer ' ] = $ referrer ;
305
+ }
306
+
307
+ // Send request.
308
+ return $ this ->post (
309
+ sprintf ('forms/%s/subscribers/%s ' , $ form_id , $ subscriber_id ),
310
+ $ options
311
+ );
258
312
}
259
313
260
314
/**
0 commit comments