You are here

Simplenews - How to subscribe all existing users?

To add all users that are not already subscribers run this query:

insert into simplenews_subscriber(activated, mail, uid)  select 1, mail, uid from users where uid not in (select uid from simplenews_subscriber) and uid > 0;

And to subscribe them to a newsletter run this query:

insert into simplenews_subscription(snid, tid, status, timestamp, source) select snid, #, 1, unix_timestamp(), 'manual' from simplenews_subscriber where snid not in (select snid from simplenews_subscription);

If you have some user susbcribed and other not:

DELETE FROM `simplenews_subscription` WHERE `tid` = 104;

and then:

insert into simplenews_subscription(snid, tid, status, timestamp, source) select snid, #, 1, unix_timestamp(), 'manual' from simplenews_subscriber;

# = newsletter number

code type: