We’ve improved our subscriber_edit API method to allow for updating only a portion of subscriber details, rather than supplying the entire subscriber record for each update.
The default behavior of subscriber_edit
remains the same – you must build the entire subscriber record each time you save any updates associated with that record. Here are example POST
parameters that you could pass:
Array ( 'id' => 1, 'email' => 'john@doe.com', 'first_name' => 'John', 'last_name' => 'Doe', 'field' => Array ( '2,4' => 'field value', ), 'p' => Array ( '3' => 3, '5' => 5, ), 'status' => Array ( '3' => 1, '5' => 1, ), )
With potentially lots of lists and custom field values, this array becomes very large when you often only want to update a single value pertaining to the subscriber.
In these cases you can include the overwrite
parameter in the API request URL. Set it to 0
to turn off automatic overwrite.
Here is an example API request URL for subscriber_edit
:
http://mysite.com/admin/api.php
?api_user=admin
&api_pass_h=098f6bjdsa87sadhsj4e832627b4f6
&api_action=subscriber_edit
&api_output=serialize
&overwrite=0
If you include the overwrite
parameter, it can be value 1
or 0
. Leaving it out defaults to 1
.
Now here is your modified POST
parameters:
Array ( 'id' => 1, 'p' => Array ( '6' => 6, ), 'status' => Array ( '6' => 1, ), )
Here we are only appending this new list (ID 6) for the subscriber record, and all other details are left alone (if overwrite=0
). Please keep in mind if you leave out some parameters that have dependencies (such as p
and status
), you might receive an error or have incomplete data being saved.
The only required parameter is id
. Here are a list of dependencies:
p
andstatus
are dependent on each other.first_name
requires eitherp
orfirst_name_list
.last_name
required eitherp
orlast_name_list
.
Let us know if you have any problems with this new functionality!