Command to remove or unsubscribe single subscriber

I’m searching for a command line function to remove a single subscriber, but I can’t find anything. Here is my use case:

I’m using phpList as a “member notification” system, rather than a typical marketing tool. So the subscribers won’t ever interact directly with phpList to subscribe or unsubscribe.

We provide services to our members. Our account management system adds new members to a CSV file with various attributes. I’m planning to use the SubscribersPlugin to automatically import the members into phpList for two purposes:

  1. Using the AutoResponderPlugin, we will send a “welcome” email with their account information.
  2. We will use the List to send occasional emails about maintenance windows, upgrades, etc…

When a member leaves, we need to automatically remove them from the list at the same time we close their account.

I can obtain the email address for a closed account to use in a script. But I need a command to run. I’ve thought about just trying to remove the subscriber from the database, but due to various tables being used, I’m thinking it could get “messy”.

Does anyone have an idea of how to do this in a clean and safe manner? Thanks for any ideas!

@bhotrock The “blacklistemail” page will blacklist a subscriber, which will stop phplist from sending to them. It can be run from the command line using the -p parameter using -e for the email address.

Thanks @duncanc ! I was able to do the blacklist command and it worked. However, since blacklisting is “permanent”, should a former member (who would now be blacklisted) re-join, the automated process would not be able to “un-blacklist” this person in order to send their new account details.

I understand that I’m using phpList in an unusual way, and that it’s not designed for this. Just trying to figure out if there is a way to work around some of the “best practice” functions (good) that are built in.

@bhotrock That is correct. Just importing an email address will not change the blacklist status. I am looking at adding a feature to the Subscribers plugin to delete a subscriber from the command line.

@duncanc Deleting from the command line would be great! I’ve been trying to figure out options for setting and resetting the confirmed attribute. The delete solution would be much better!

If you’re up for a bigger challenge… :slight_smile:
It would be really cool for the CSV import process to have some sort of optional “flag” that would remove any subscribers that are not included in the CSV file. That way the CSV becomes an external authority for the subscriber list.

Just figured I’d throw that out for a wish list. But seriously, thank you so much for your willingness to add any new features. Your work is greatly appreciated!!!

@bhotrock I found that phplist already has a way to run commands from the command line, which I think is simpler than extending the plugin.

If you unzip the attached file and copy to the admin/actions directory then it can be called from the command line but adjusting for where phplist is installed and setting the email address. Note that the email and command parameters must appear before the -p and -c parameters.

php /home/duncan/www/lists/admin/index.php email=foo1951@test.com command=deletesubscriber -c /home/duncan/Development/PHP/phplist/config.php -p runcommand

deletesubscriber.php.zip (441 Bytes)

1 Like

@duncanc Thanks so much for this!! It works perfectly!

I’ve really appreciated your help!