4

I'm running into some trouble adding my own CiviRule action. I've been able to add the action to the civirule_action table and confirmed it's showing up in the list of actions in the UI. Whenever I try to save the action in a rule I get the error, "Not a valid action, action class is missing".

I'm not sure if I have placed my php class file in the right location or if something else needs to be done. I'm running Wordpress 4.9.7, CiviCRM 5.2.2, and CiviRules 2.1. The php file is placed in /wp-content/plugins/files/civicrm/org.civicoop.civirules/CRM/CivirulesActions/

What could I be missing?

  • 1
    To be sure. I think the path is ... files/civicrm/ext/org.civicoop.civirules/CRM/CivirulesActions/ – Kainuk - CiviCooP Jul 27 '18 at 6:13
1

In Create your own action you find a description for extending CiviRules with a custom action. The example action SoftDelete has the class CRM_CivirulesActions_Contact_SoftDelete should be placed in the file ../ext/org.civicoop.civirules/CRM/CivirulesActions/Contact/SoftDelete.php

It is also possible to add a custom action to your own extension. An example of such an extension can be found at https://github.com/CiviCooP/org.civicoop.wpcivirules . (But be aware old versions of CiviRules worked with managed entities (*.mgd.php) files. This still works but the latest version works with direct sql statements).

  • It sounds like I am on the right path, but unfortunately it's still not working. I've placed my custom action (AddMembership.php) in the CivirulesActions folder and I'm still getting the same error message. The example in the create your own action doesn't seem too difficult so I'm not sure where I'm going wrong. Here is a link to my action. [link] gist.github.com/jimmy-tdr/6818c315ce44f7dda79778751a4be1be – Jimmy Penlesky Jul 31 '18 at 5:36
0

The class name relates directly to the path where that class should be found. Placing the file containing your class directly into CRM/CivirulesActions won't work, though it is the correct starting point.

Your class name in the gist you posted is "CRM_CivirulesActions_EA_Membership_Add", which means Civi expects to find the class in this location:

CRM/CivirulesActions/EA/Membership/Add.php

There may be another issue: in the working examples I've seen, the path is always CRM/CivirulesActions/EntityName/ActionName.php - I don't know whether this is mandatory, but if changing the path as suggested above doesn't work then you may also need to change the class name and path to match this format.

I haven't tested a modification of your code to check that this works, but I have just set up a custom CiviRules Action in an extension of my own, so if this doesn't lead you to the answer then post back and I'll see if I can help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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