Hot answers tagged

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


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


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

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

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

[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

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

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

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 need to install the core module Actions first to be able to configure action plugins in UI. Then you can access the actions overview page: /admin/config/system/actions On the top of the page your new plugin should be present in the select list for creating advanced actions. When you select the plugin you should see the configuration form of your plugin: /...


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

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

As said by @drupality function hook_node_insert($node) { if ($node->type != 'job_posting') { return; } $node = new stdClass(); // Create a new node object $node->type = "test"; node_object_prepare($node); // Set some default values $node->title = "YOUR title"; $node->language = LANGUAGE_NONE; // Or e.g. 'en' if locale is enabled $node-&...


2

The simple bulk action support in Drupal 8 core does not currently support this feature.


2

Even adding something as simple as drupal_set_message doesn't result in a message being displayed. That's the expected behaviour - in the logout hook, you're still inside the authenticated user's session. Once they're logged out, you're not any more. So messages intended for that user are no longer there, because that session has been destroyed. You ...


2

The solution here was to set the permission I want in the access_callback of the custom entity itself. so in my case the hook_entity_info 'access callback' => 'myentity_access_callback', then added this in a function function myentity_access_callback($roles = array()) { // $op, $application = NULL, $account = NULL global $user; $roles = array( '...


2

Check out the Logging and Alerts module.


2

Awhile back I did come up with a work around for this. Basically you can create a custom submission handler for the VBO form, then have that custom handler perform the code you need. /** * Implements hook_views_bulk_operations_form_alter(). * * This is the function that alters our VBO form * * @param $form * @param $form_state * @param $vbo */ function ...


2

Sounds like a job for hook_user_delete(): Respond to user deletion. This hook is invoked from user_delete_multiple() before field_attach_delete() is called and before users are actually removed from the database. Modules should additionally implement hook_user_cancel() to process stored user data for other account cancellation methods. e.g. ...


2

As per the "I'm not very experienced in development", you may want to use an alternative approach which only requires site building skills, as further explained below ... Use the integration of the Privatemsg module with Rules instead (make sure to checkout this community docu, and its child pages ...), together with the Views Bulk Operations module. For ...


2

You just need to use drupal_session_regenerate(), you can see the use of this function here. All you have to do is either play with Uid or if you want to do this for anonymous user then you just create a user xyz and use that ID for session regenerate. You can grab the UID from URL for different users like www.example.com/custom-url-to-login/125 or www....


2

This works: $action = \Drupal::entityTypeManager() ->getStorage('action') ->load('send_mail'); if ($action) { $action->execute($entity); }


2

Provided you use the Views Bulk Operations contrib module, you can use code similar to the following, inside the buildConfigurationForm() method. Most importantly, you need to extend ViewsBulkOperationsActionBase instead of ConfigurableActionBase. class YourAction extends ViewsBulkOperationsActionBase ... public function buildConfigurationForm(array $...


2

D7, install Conditional rules module, this module let's you add aditional conditions at action section in rules UI. You say your event is 'checkout proccess', so, the first thing you need is to load your 'pizza' node object in to rules, I am assuming that you have a field in your product-fields referencing to your 'pizza-content-type'. To do this, in ...


1

views bulk operations (https://www.drupal.org/project/views_bulk_operations) gives a special views field that will allow you to bulk change fields bulk_update_fields also promises exactly that. Its a new module for drupal 8 and seems to work with some warnings (in my case) you can install it stand alone and go to content/node and use it as action bulk ...


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