Home Forums Newsletter Plugin Support API changing list not working

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #304761
    go! Presse GmbH
    Participant

    Hey,

    i use the v2 api (and even tried v1) and want to change the lists of subscribers. I am able to modify subscriber data on the PUT endpoint like “/wp-json/newsletter/v2/subscribers/user7@example.com” with following query. Everything is altered except the lists. Using the v1 api in the documented way also will not alter the lists but everything else. I use the most current version of the plugin and the api plugin. This is really important for my use case, help would be appreciated.

    Cheers.


    {
      "first_name": "string",
      "last_name": "string",
      "country": "st",
      "region": "string",
      "city": "string",
    "lists": [
    {
    "id": 2,
    "value":1
    }
    ],
      "list_N": 0,
      "gender": "F",
      "status": "confirmed"
    }

    #304763
    Stefano
    Keymaster

    Hi, is list 2 defined with a list name?

    #304775
    go! Presse GmbH
    Participant

    Yes it is. And I also tried multiple public and private lists.

    #306040
    Mark Pietrusinski
    Participant

    I am also unable to get new subscribers created via POST /subscribers to be assigned to a list. They are created without being assigned to any list at all regardless what id value is given.

    Furthermore, the V2 api documentation does not indicate what is the purpose of the request data list “value” and “list_N” properties.

    `
    “lists”: [
    {
    “id”: 2,
    “value”:1 <– ?
    }
    ],
    “list_N”: 0, <– ?
    `

    #306041
    Mark Pietrusinski
    Participant

    I got it working for my integration after digging into the newsletter_api code. In the request list objects, value needs to be 1. Also subscribers will not be added to private lists unless the request is authenticated.

    The list_N parameter is an interesting one…
    It seems that list_N should actually be one or more dynamic properties where N is can be replaced by a list id.

    This looks like code handling that part of the request:

    // Manage list_N parameters
    $nls = $newsletter->get_lists();
    foreach ($nls as $nl) {
    if ($request->has_param('list_' . $nl->id)) {
    if ($authenticated || !$nl->is_private()) {
    $data->lists[$nl->id] = $request->get_param('list_' . $nl->id) ? 1 : 0;
    }
    }
    }

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.