back to

Is it possible to subscribe to specific list from subscription page through AJAX?


I have created a subscribe page in phplist that offers users an ability to sign up for 3 different lists (at the moment, there might be more in the future).

I’ve also created a landing page on my website with an AJAX form that is meant to promote one of the lists from above and allow users to subscribe only to that one specific list. I’ve based my AJAX form on this wiki here:

The code is working, the users are subscribing properly from my landing page BUT there’s one problem. Even though the specific list ID seems to be defined in the AJAX form code, the users are still being subscribed to all 3 lists at once. Why?

Is this the limitation of AJAX subscription? Or can I somehow define specific list ID in the AJAX form so the users will sign up only for one specific list?

I know that I can make a workaround and create a separate “subscribe page” in phplist and check only that 1 list there and use it for AJAX form. But this raises another problem: when user tries to access his preferences page, he’s tied to the last subscribe page he used. So if he first signed up for list #1 and #2 from the traditional subscription page that offers all 3 lists and THEN he would sign up for list #3 through my landing page with AJAX form tied to different subscribe page that only offers list #3, then on his preferences page he’s going to see only that list #3. He won’t see the list #1 and #2 from other subscribe page and won’t be able to manually uncheck the previous lists. That’s why I want to have only 1 subscription page and just control with the AJAX Form to which list the user will be assigned. Is it possible?

@blazej I have raised this as an issue on Github and it looks like some sort of change will be made.

If you can wait until the change is decided then you can modify your ajax form and index.php accordingly.

Or you could try using the subscribe page, instead of asubscribe. That will return an html page,which you could ignore assuming that the subscription was successful.


Hey Duncan,

First of all, thank you! I really appreciate the help.
When the feature is implemented, I’ll adjust the AJAX form accordingly to support new, proper implementation.

At the moment I made a small workaround. I created a new subscribe page for each AJAX form I have. So right now I have three subscribe pages - the first one (subscribe page id = 1) offers the choice of all lists (#1, #2, #3) and the two remaining pages are tied only to specific list (one page for list #2, other page for list #3) for AJAX purposes.

I’ve connected the AJAX form with specific subscribe pages, so people are subscribing only to specific list.

As for unsubscribing, I’ve modified everywhere the link to [PREFERENCESURL] - I turned it into “[PREFERENCESURL]&id=1”. When the user clicks the link, he gets the preferences page from subscribe page #1 that contains all the lists, so he can see all the lists, regardless how he subscribed, and uncheck the ones he doesn’t want :slight_smile:

A bit of a mess with too many pages, but oh well, for the time being it will be fine and I’ll switch it to proper implementation once it’s out.

Again, thanks for raising my issue on GitHub and take care!