Hot answers tagged

12

Here is the way, I found for D7... /** * Implementation of hook_action_info(). */ function MODULE_action_info() { $action = array( 'MY_ACTION_NAME' => array( 'label' => t('MY ACTION LABEL.'), 'type' => 'node', 'configurable' => FALSE, 'triggers' => array('any'), ), ); return $action; } /** * Action ...


7

I'm glad this question was asked some time ago, and Thanks to @coderama for offering a bounty for this. I make questionnaires/challenges to Druplars in my local community, and this was a question there. PHP allows you to set error and exception handlers. This similar to how you register class autoloaders and shutdown functions. See set_error_handler ...


7

Drupal core doesn't provide this functionality, so yes, you need to implement it yourself. Yes, you can implement your own action plugin to do this. You can also have a form to select which tag you want to apply. Have a look at the node delete action plugin, which uses a confirmation form, but you can implement whatever functionality you want in that form. ...


6

Using the "Entity has field" (or "content is of type") condition will make the fields become available with data selection in the Action "Set a data value".


6

A "universal formula or module to create custom rules actions, events and conditions" (as is your question), is to write a custom module. To do so, you either create a new module, or you extend any of your existing custom modules. Refer to Drupal custom Rules how to write your own events conditions, actions and custom object (+custom tokens) for a great ...


5

First, an explanation of why the changed timestamp gets updated. Actions can declare the attribute 'behavior' => array('changes_property') in their hook_action_info entry. This attribute causes VBO to automatically call Entity API's entity_save function after the action has been called. This function ends up calling node_save, which updates the changed ...


5

if its a rule action component than it should be called by rules_invoke_component('name', $other_parameters..); while rules_invoke_event() is suppose to trigger an event on which you might have different rules to act on.


5

You need both an action plugin and an action config entity Create the plugin with drush: drush generate plugin-action Create the action config entity: look at "system.action.comment_delete_action.yml" for an example. After creating these, clear the cache and it should be available in views under the label "Bulk update".


4

Hooks are one concept, and actions-and-triggers are a separate concept. See What is the basic concept behind hooks? for the canonical explanation of hooks (there are some excellent answers to that question, there would be no point in trying to reproduce them here). Actions and Triggers are best explained in Using the new Actions and Triggers functions in ...


4

If you are talking about the $context variable (and I think you do), then the official description is: an associative array containing extra information about what triggered the action call, with $context['hook'] giving the name of the hook that resulted in this call to actions_do() (from here: http://api.drupal.org/api/drupal/includes!actions.inc/function/...


4

I don't know of any modules that enable you to write db records in rules actions. I guess you could write a custom rules action to write to your custom table and grab all the data in rules but it's just as easy to do something like below using hook_commerce_checkout_complete: The trickiest part is obtaining the SKU <?php function ...


4

In Rules 2.x on Drupal 7, there is a "Create entity" action built-in to the Rules module itself. You can use this action to create a node (Content), which is one type of entity.


4

Berdir's answer is accurate, you must write your own action. I found this article extremely useful to quickly achieve this. Basically when you create and registering a new action you can specify a 'confirm form', eg 'Are you sure you want to do this?'. You can provide a form for this stage that accepts more information and then uses that information to ...


4

As an alternative to the cron job, this sounds like the queue system might be better. The main difference is that in your hook_cron(), you have to execute queries to find data to process. With a queue, you listen to new entities being saved (hook_entity_insert()) and put them in your queue. Then Drupal will manage the list of tasks (queue items) and will ...


4

You should inject the plugin manager as a service if possible, but for a plugin (code) based action: $manager = \Drupal::service('plugin.manager.action'); $action = $manager->createInstance('action_plugin_id') $action->execute(); Or if it's an advanced action, it's a config entity, so load and execute it that way: $action = \Drupal\system\Entity\...


3

You can set permissions on rule component page in fieldset at the page bottom. There is an option "Configure access for using this component with a permission."


3

Drupal supports logging exceptions, although I am not sure if it will automatically log all uncaught exceptions if a module neglects to handle them. For email alerts, I would look at Monolog or Logging and alerts. Assuming the log contains everything you want, those modules will let you send an email if a log entry is above a certain severity.


3

There is no button or link or even an indication that orphans exist when going to /admin/config/system/actions. I don't really get why, but when I visit /admin/config/system/actions/orphan the orphaned actions are removed. I'm watching the Drupal log when I go to that path and it systematically removes all the orphans.


3

[I'm assuming you have a custom table to store these email addresses and are not related to any other entity] With the latest version of VBO, yes, you have to define an Entity. See this issue in the VBO queue for more information. FYI, the below steps worked for me. function module_entity_info() { return array( 'MY_NEW_ENTITY_TYPE' => array( ...


2

You can use the Rules module, a more powerful version of actions and triggers. Configure a rule as follows: React on event: (Node) After saving new content Action: (System) Send mail to all users of a role However, you cannot select the authenticated role here. Instead, you will have to add another role to your site and use it instead. (You can create ...


2

Check out the Logging and Alerts module.


2

Just a note -- For Drupal 7, IMO @tanmayk's answer is best -- define the action in your custom module using hook_action_info() and the action will then appear in the Configuration > System > Actions window as well as in the VBO list. But remember that you have to permit the user to use the action (People > Permissions)! Thanks to @autopoietic for triggering ...


2

Not to contradict both prior answers, but IMO they are both missing (ignoring?) a crucial part of the question, which is "...I created an Action Set...". True, part of the solution is, pretty sure, "Entity has field" (as in the answer from jcarballo). But, by design of a Rules Action Set, you cannot include any Rules Condition in it. Therefor, either of the ...


2

You don't do it at once, you generate the document page by page (item by item). The document gets created on first run, and on the last run you do whatever cleanup you need. See archive.action.inc that ships with VBO for an example of this approach. You can mark your action as "aggregate", and get all rows, but that's going to significantly limit the ...


2

You have two ways to do this. Either you use PhP filter, which will add under "data selector" and "add offset" a new option, "php evaluation", which will allow you to post-treat this value. Then you'll just have to set return intval(- $value); Or you can use whole Rules, by : Action: Add a value, and select your [node:field-labpoints] Action: Calculate a ...


2

I know that you specifically asked about Rules, but you might also consider using Drush for this. For example, if you want an email to be sent to you every time an error appears on your status page, you could just drop this one line into your crontab: 0 */1 * * * /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /bin/...


2

This answer is slightly experimental as I have done something similar but not precisely the same. You may need to do further work, but here's the outline which will require a custom module that uses Entity API. What it does is create a custom node property which says where it was updated from: Implement hook_node_submit() to check which form the node update ...


2

Add requestee relation. Add context filter by user id (set it on current user with requestee relation). Add filter criteria by relationship status. Here you can see screenshot of view.


2

Currently there is no rules condition to do this but there is a patch in the rules issue queue. You can try using that, and if you do you can report back to that issue and help it get committed to the rules module. http://drupal.org/node/1421058#comment-6532372


2

If you visit /admin/config/system/actions you will see a list of the actions currently on your system. These actions are declared in the modules (named under Action Type), and may be orphaned if a module is de-activated. Clearing orphaned actions is fine, but if you drop the table, you will break your site.


Only top voted, non community-wiki answers of a minimum length are eligible