Answers.Body: <p>great that you are trying to add your own actions! And great that you are sharing your exerience with the documentation here.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-06T23:42:38.857Z
Answers.Text: 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".
Answers.UserDisplayName: Rachelle Niemela
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-06T23:46:53.407Z
Answers.Text: Just checked the database itself. The new item shows up in civirule_action
Answers.UserDisplayName: Rachelle Niemela
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-06T23:48:48.640Z
Answers.Text: Do you want me to post the contents of the files?
Answers.UserDisplayName: Rachelle Niemela
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-07T00:05:40.130Z
Answers.Text: 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.
Answers.UserDisplayName: Rachelle Niemela
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-07T08:51:58.760Z
Answers.Text: Cool!! Keep my fingers crossed :-)
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-30T15:44:55.330Z
Answers.Text: @ Rachelle, did you manage to finish creating your action and testing it?
Answers.UserDisplayName: Sudesh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-06T08:47:30.210Z
Answers.LastActivityDate: 2018-02-06T08:47:30.210Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>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. </p>
  
  <p>Using Wordpress 4.92, Civicrm 4.7.27, CiviRules 1.17</p>
  
  <p>Am looking here: <a href="https://docs.civicrm.org/civirules/en/latest/create-your-own-action/" rel="nofollow noreferrer">https://docs.civicrm.org/civirules/en/latest/create-your-own-action/</a> but am having a hard time understanding exactly what I need to do to add an additional action. </p>
  
  <p>"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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>"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(&amp;$entities) hook that is in <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed/</a>?</p>
  
  <p>I attempted to use create a hook directory as per <a href="https://docs.civicrm.org/dev/en/latest/hooks/setup/wordpress/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/setup/wordpress/</a> 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 <a href="https://civicrm.org/blog/haystack/working-with-civicrm-46-in-wordpress" rel="nofollow noreferrer">https://civicrm.org/blog/haystack/working-with-civicrm-46-in-wordpress</a> 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."</p>
  
  <p>Help please!! Step 2 and 3 I can easily do, but Step 1, not so much.</p>
  
Tags: <wordpress><civirules>
Title: Add CiviRules action
ThreadText: # Add CiviRules action
  
  (Asked by: username_0 on 2018-02-04)
  
  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.
  
  **Tags:** wordpress, civirules
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-02-06. Score: 3 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: 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".  
  > **username_0**: Just checked the database itself. The new item shows up in civirule_action  
  > **username_0**: Do you want me to post the contents of the files?  
  > **username_0**: 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.  
  > **username_1**: Cool!! Keep my fingers crossed :-)  
  > **username_2**: @ Rachelle, did you manage to finish creating your action and testing it?  
  
  ---
  
  