The Task Is :
sending emails To users with a specific role to edit content which added by specific user
eg:send email to x when y add a new content
What I did: l
1-make a rule send_e_mail_to_editors_on_creation
2-Events:After saving a new content
3-Conditions:a.Content is of type"article"
b.And
c:Execute custom PHP code
the code:

   $author_uid = token_replace('[node:author:uid]', array('node' => $node));
  if
($author_uid =1)//the id of author of article

{

return TRUE;    
}
else {
  return FALSE; 
}

4- actions: Send mail to all users of a role

the result
sending emails about all new content not content from user y only

Comments

saurabh.dhariwal’s picture

Issue summary: View changes

Please follow the below steps:

Step 1: create custom rule event

function MODULENAME_rules_event_info() {
  return array(
    'event name' => array(
      'label' => t('text'),
      'module' => 'MODULENAME',
      'group' => 'groupname' ,
      'variables' => array(
        'current_user' => array('type' => 'user', 'label' => t('The current logged in user.')),
        'node' => array('type' => 'node', 'label' => t('node object.'))
      ),
    ),
  );
}    

Step 2: Alter your node presave and call your custom event which you create.
Create your custom code to retrieve user list and pass it in your rule event and if its multiple then call it in loop.

i.e.

foreach($user_object_array as $user){
                        rules_invoke_event('event name', $user, $node);
                }

Step 3: Create your rule with custom event and set action send to email where email will retrieve from $user object which pass in custom rule event.

Let me know if any query/concern regarding this.

Thanks!

tr’s picture

Version: 7.x-2.3 » 7.x-2.x-dev
Assigned: heba2012 » Unassigned
Priority: Critical » Normal
Status: Active » Closed (works as designed)

Suggestion was made in #1, original poster did not follow up.