Please what is the best way to setup notifications for a specific drupal role and content type? I have installed the latest 4.x dev modules (notifications, messaging, notifications_extra) but its not obvious. Thanks for your help.

Comments

jose reyero’s picture

Status: Active » Fixed

No subscription to roles supported yet.

Status: Fixed » Closed (fixed)

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

enkara’s picture

I would love this feature. Is anything related to this been made after a year?

Anonymous’s picture

subscribing

baff’s picture

subscribe

zeezhao’s picture

dup removed...

zeezhao’s picture

Status: Closed (fixed) » Active

The way i did this in the past is via specific code e.g. using $rid as ID of role:

function mymodule_subscribe_role($node, $rid)
{
  	$result = db_query("SELECT u.uid, u.name, u.status FROM {users} u
    	INNER JOIN {users_roles} ur ON u.uid=ur.uid WHERE ur.rid = %d
    	AND u.status = 1", $rid);
	while ($u = db_fetch_object($result)) 
	{
       		$account = user_load($u->uid);
	      	if (!empty($account->uid)) 
        		mymodule_notifications_subscribe_user($account, 'thread', 'nid', $node->nid);
	}
}

function mymodule_notifications_subscribe_user($account, $type, $field, $value) 
{
  	if (!notifications_get_subscriptions(array('type' => $type, 'uid' => $account->uid), array($field => $value))) 
	{
    		$subscription = array(
      			'uid' => $account->uid,
      			'type' => $type,
      			'fields' => array($field => $value),
    		);
    		notifications_save_subscription($subscription);
  	}
}

Has anyone been able to do it via interface?

ajf7688’s picture

Hi i had written a code similar to your code.. But my code is more of using notifications_save_subscription($subscription); to subscribe an array of users to a thread as its being created

My users in my array do get subscribed they also go into the queue but my emails to them dont seem to go out

Any Idea regarding this? Does notifications_save_subscription($subscription); send the notifications too if used on node insert? Or is there another function to trigger the actual sending?

Thank You

zeezhao’s picture

Ensure users have appropriate "subscribe to" permissions set under "notifications_content" section of permissions page.

ajf7688’s picture

Yes thanks it was a permission issue!