On rules settings page (admin/config/workflow/rules) and components page (admin/config/workflow/rules/components) you can specify action (like 'send e-mail') for each of rule or component.

How can I get pragmatically all certain (e.g.: 'send e-mail') actions from Rules and Components?

1 Answer 1


This function should do the trick:

 * Find all rules with action name matching a string pattern
 * @param $pattern
 *  String pattern to check action names
 * @param $active
 *  Boolean whether to limit the search to active rules only
 * @return
 *  Array with rule names with actions matching the pattern as keys and arrays of rule 
 *  action names as values
function search_rules_for_action($pattern, $active_only = TRUE) {
  $active_only = ($active_only) ? array('active' => 1) : array();
  $rules = rules_config_load_multiple(FALSE, $active_only);
  $matching_rules = array();
  foreach ($rules AS $rule_name => $rule) {
    if (method_exists($rule, 'actions') === TRUE) {
      foreach ($rule->actions() as $action) {
        if (method_exists($action, 'getElementName') == TRUE) {
          $action_name = $action->getElementName();
          if (stripos($action_name, $pattern) !== FALSE) {
            $matching_rules[$rule_name][] = $action_name;
  return $matching_rules;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.