Last active
December 29, 2015 12:49
-
-
Save miteshmap/7673018 to your computer and use it in GitHub Desktop.
Implements hook_rule_condition_info - add condition to rules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Implements hook_rules_condition_info() | |
| */ | |
| function foo_rules_condition_info() { | |
| return array( | |
| 'foo_check' => array( | |
| 'label' => t('Check foo condition'), | |
| 'parameter' => array( | |
| 'param' => array( | |
| 'type' => 'list<text>', | |
| 'label' => t('foo label'), | |
| 'options list' => 'callback_function_to_return_options', | |
| 'description' => t('The condition to check for.'), | |
| 'restriction' => 'input', | |
| ), | |
| ), | |
| 'base' => 'callback_function_to_validate', | |
| 'group' => t('System'), | |
| ), | |
| ); | |
| } | |
| /** | |
| * Condition implementation: Check if param and condition is equal or not. | |
| */ | |
| function callback_function_to_validate($param) { | |
| $current_value = get_current_value(); // get the current value to check against condition value. | |
| return in_array($current_value, $param); | |
| } | |
| function callback_function_to_return_options() { | |
| return array(1 => 'value1', 2 => 'value2', '3' => 'value3'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment