2

I am starting to experiment with civirules, and it looks like it's going to help a lot for automated workflows. There are some actions that are missing and am interested in playing to add more.

Using Wordpress 4.92, Civicrm 4.7.27, CiviRules 1.17

Am looking here: https://docs.civicrm.org/civirules/en/latest/create-your-own-action/ but am having a hard time understanding exactly what I need to do to add an additional action.

"It is pretty simple (at least that is what we think) to add your own actions to the CiviRules Engine. You can either do that by adding it to the CiviRules extension or by creating your own extension and including your own action." Well it doesn't seem simple because I can't find a simple way of doing this.

There's some existing action items that would easily serve as templates for what I want to do, so I'd like to add an additional action to the existing CiviRules extension.

I've attempted to code additional mgd.php and .php files in the appropriate folder structure. But when I do this, the class isn't registered in the database - obviously.

"If you didn't create your extension with civix you should add the hook_civicrm_managed_entities to your extension and return the array below." How do I do this exactly if I'm adding to the existing extension and not creating a new one? Where do I put the hook? What's the syntax? I've never worked with hooks before. I've Google searched for hook_civicrm_managed_entities but I'm not sure what this is as it doesn't return anything. Is this the hook_civicrm_managed(&$entities) hook that is in https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed/?

I attempted to use create a hook directory as per https://docs.civicrm.org/dev/en/latest/hooks/setup/wordpress/ and use the code that is recommended and that broke my site. The info in this doc seems to imply that it relates to WordPress 4.6, and the link https://civicrm.org/blog/haystack/working-with-civicrm-46-in-wordpress has a comment that says the civicrm_managed_entities hook won't work properly with WordPress? "Tim Otten reminded me (thanks Tim) that there's another hook which won't behave as expected in WordPress, which is 'hook_civicrm_managed'. Callbacks work fine but, at present, there's no logic for managing the entities in WordPress. Another one for the roadmap, logged here for reference."

Help please!! Step 2 and 3 I can easily do, but Step 1, not so much.

1 Answer 1

3

great that you are trying to add your own actions! And great that you are sharing your exerience with the documentation here.

If you added a .mgd.php file you will have to do a '/civicrm/clearcache' to make sure that your class is registered. Did you do that? If not give that a try and that might fix your issue.

6
  • Added an .mgd.php file and a .php file. I'm on WordPress, so did [site-url]/wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/job&action=export&id=13&reset=1 When I try to add the action, I get "Not a valid action, action class is missing". Commented Feb 6, 2018 at 23:42
  • Just checked the database itself. The new item shows up in civirule_action Commented Feb 6, 2018 at 23:46
  • Do you want me to post the contents of the files? Commented Feb 6, 2018 at 23:48
  • Aha! Found an error in the php file. Corrected that and it registered properly. Now on to testing what the new action is supposed to do. Commented Feb 7, 2018 at 0:05
  • Cool!! Keep my fingers crossed :-) Commented Feb 7, 2018 at 8:51

Your Answer

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

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