Breaking

Followers

Saturday, 15 July 2017

Create custom rule in Drupal 7


Let’s start with the announcement hook_rules_event_info (), which also should be placed in the file module.rules.inc
/**
* Implementation of hook_rules_event_info().
* @ingroup rules
*/

function nirvana_like_rules_event_info() {
  return array(
    'nirvana_like_skill_endorsed_plus' => array(
      'label' => t('After adding skill endorsed'),
      'module' => 'nirvana_like',
      'group' => 'Skill endorsed',
      'variables' => array(
        'skill_userid' => array('type' => 'user', 'label' => t('This id of accept a bid.')),
        'skill_tid' => array('type' => 'taxonomy_term', 'label' => t('The user who is post node.')),
        'endorsed_user_id' => array('type' => 'user', 'label' => t('The posted node services or task.')),     
      ),
    ),
   
  );
}
Now, invoke this event in your custom function.

Ex.
function hook(){
  rules_invoke_event('nirvana_like_skill_endorsed_minus',user_load($_POST['skill_user']),taxonomy_term_load($_POST['tid']),user_load($_POST['endorsed_userid']));
}


Hope it will work what you are looking for!

No comments:

Post a Comment