Hi, I have set the notifications module to automatically subscribe new users to any newsletter issues but it doesn't work. I have subscribed them in the categories and content type sections but when I create a new user they are not subscribed. Any ideas?

Comments

vstmusic’s picture

Actually, I do that with adding php code in user.module (user module) and it work !

my php code :

(you must modify the code with your own content type names ...

 // SUBSCRIPTION to newsletter
    $user_id = $array['uid']; 
    $SQL_INSERT = "insert into drupal_notifications (uid, type, event_type, conditions, send_interval, send_method, cron, module, status) values ('%s', 'nodetype', 'node', '1', '0', 'mail', '1', 'notifications', '1')"; 
    
    foreach(array("FIRST_CONTENT_TYPE_NAME", "SECOND_CONTENT_TYPE_NAME") as $v)
    {
        $sql = sprintf($SQL_INSERT, $user_id); 
        db_query($sql);    
        $last_id = db_last_insert_id('notifications', 'sid');
        $sql_notif = sprintf("insert into notifications_fields (sid, field, value) values ('%s', 'type', '%s')", $last_id, $v); 
        db_query($sql_notif);
    }

It is perhaps possible to write this php code in workflow module...

I hope this will be implemented in a next version of notifications module ! :-)

jose reyero’s picture

For this either we create a specific plug-in, so you can subscribe to a newsletter as such, or we subscribe the users to whatever node types are the newsletter posts.

For creating subscriptions, better use the notifications API: notifications_add_subscription()

jose reyero’s picture

Status: Active » Closed (duplicate)

About automatic subscriptions, follow up here #304010: Suscribe new users to all content