I have created a newsletter and want to mass subscribe my existing 300+ users. Do I have to export all user emails by hand and then copy them into the mass subscription field?

Svend

Comments

STNyborg’s picture

Status: Active » Fixed

Problem solved the hard way with a SQL-command updating the simplenews subscriptions by combining all ACTIVE users together with the new newsletter.

INSERT INTO `simplenews_subscriptions` (`activated`, `mail`, `uid`) SELECT 1, users.mail, users.uid FROM users WHERE users.status=1;

INSERT INTO  `simplenews_snid_tid` SELECT simplenews_subscriptions.snid, (SELECT term_data.tid FROM `term_data` WHERE term_data.name='NAME-OF-NEWSLETTER') FROM `simplenews_subscriptions`;

Perhaps it is not pretty, but it solved my problem. Note that you must replace NAME-OF-NEWSLETTER with the name of your own :D

However the solved problem I suggest that this should be done at the frontend of Drupal in the subscription section of the newsletter.

Svend

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

astridman’s picture

Status: Closed (fixed) » Active

wait, wait, wait...hate to re-open but isn't there a more elegant solution to this problem than yanking out the table smacking it in the face?

sutharsan’s picture

Status: Active » Closed (won't fix)

The closest thing is the Simplenews Roles module but unfortunately it is not stable, not (actively) maintained and not ported to D6.

astridman’s picture

STNyborg, your SQL command did indeed work, thank you very much! One caveat for others attempting (I did mine through PHPMyAdmin) ...I had one user subscribed to the newsletter in question and I got an error back. I guess ALL users must NOT have a subscription to the newsletter prior to running the command.

astridman’s picture

wait, no, I just discovered that the command doubled EVERY USER in the DB. drat.

open source is AWESOME.

drein’s picture

any idea on how to do this query in drupal5?
sorry but if I write:

INSERT INTO simplenews_subscriptions (activated, mail, uid) SELECT 1, users.mail, users.uid FROM users WHERE users.status=1;

I receive this answer:
user warning: Unknown column 'activated' in 'field list' query: INSERT INTO simplenews_subscriptions (activated, mail, uid) SELECT 1, users.mail, users.uid FROM users WHERE users.status=1 in /var/www/vhosts/spazioausili.net/httpdocs/includes/database.mysql.inc on line 172.
Top of Form 1
Bottom of Form 1

in fact if I open the table, there isn't the "activated" column.
My knowledge of mysql is 0, but I should subscribe 150 users and I don't want to make it manually!!!!!
thanks if you can help.