Hot answers tagged

15

You first need to add a condition to check if the field exist on that node, only then it is available to the actions. There is a specific condition to do this.


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 ...


8

Explaining how to create Rule that accept arguments (user can enter any value) and adding VBO field in Views: The Power of Rules with Views Bulk Operations (and Commerce) From Joren comment: function modulename_form_views_form_test_view_page_alter(&$form, $form_state, $form_id) { $form['#submit'][] = 'modulename_vbo_submit'; $form['select']['...


6

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 ...


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

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. ...


5

You can use the Flag module to put that "button" on the node. Then using Rules you could execute a VBO or simply use rules to create that content. Don't forget to look at Rules Bonus Pack for more goodies.


5

Try to use configuration>>Actions and create new actions


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.


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

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 ...


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 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

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

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

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

[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( ...


3

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 ...


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

The best way to execute your custom code after a user logs in is by implementing hook_user_login in a small custom module you build yourself. Turn that php you wrote into a function then call it. i.e. function module_name_user_login(&$edit, $account) { module_name_user_function($account->uid); } function module_name_user_function($uid) { $usr = ...


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

I believe you're looking for hook_uc_order() which runs for several operations, including the update operation which is: Called when an order's status is changed. Assuming your module is called "hemo" you code might look something like this: function hemo_uc_order($op, $order, $arg2) { if ($op == 'update') { if ($order->order_status == '...


2

You need to create a custom module and use hook_form_alter to modify the form. That particular form id is views_form_commerce_cart_form_default, so in your custom module, you could have something like this: function mymodule_form_alter(&$form, &$form_state, $form_id) { //cart form if (strpos($form_id, 'views_form_commerce_cart_form_default') ===...


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

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 ...


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