Hot answers tagged

22

VBO has an "Execute PHP code" action. Run it, and input "node_save($entity);" (without the quotes) in the textbox. That will do the trick, while handling the timeouts for you.


20

Here's another approach. (The code is available in this sandbox.) nodemail.info name = Nodemail description = Sends node e-mails. core = 7.x nodemail.install' <?php function nodemail_enable() { $current = variable_get('mail_system', array('default-system' => 'DefaultMailSystem')); $addition = array('nodemail' => 'NodemailMailSystem'); ...


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.


14

I don't know about rules or VBO but you could use a short code snippet to get the same result: $nids = db_query('SELECT nid FROM {node}')->fetchCol(); foreach (node_load_multiple($nids) as $node) { node_save($node); } If you've got a lot of nodes that might take a bit of time so if your server allows it it'd be a good idea to extend the time limit at ...


14

Option 1: Show an image beside the Flag text You can use CSS to add padding to the left of the text and in it show a background image, as shown also in the community documentation about How to show an image beside the text. Here is an excerpt from it (replace "bookmarks" with the machine-name of your flag): .flag-bookmarks a { padding-left: 20px; } .flag-...


13

$text = token_replace('token example - [node:title]', array('node' => node_load(123)));


13

Your code seems to be OK. I use some similar code in one of my projects (this a csv importer, similar concept): function custom_function($importer_id, $csvfile_path) { // Load the Feeds Source object. $source = feeds_source($importer_id); // Load the source fetcher config. $fetcher_config = $source->getConfigFor($source->importer->fetcher); ...


12

Seemed like a useful thing to have. I created a patch for Rules, adding this functionality. I posted it in the Rules issue queue. That seemed better than providing the code directly here, as this way you can still use it anyway that suits you, yet it may actually get into core Rules. Also see this question, "How do I add a new condition in Rules 2?".


12

You can use the node_mass_update() function: module_load_include('inc', 'node', 'node.admin'); $nids = db_query('SELECT nid FROM {node}')->fetchCol(); node_mass_update($nids, array()); It's very good as you don't need to care about the time limit. Batch process for nodes update will start automatically if there are more than 10 nodes.


12

The way I solved it as follow: Events: Drupal is initializing Conditions: User has role(s) - Parameter: User: [site:current-user], Roles: anonymous user NOT Text comparison - Parameter: Text: [site:current-page:url], Matching text: user/login Actions: Page redirect - Parameter: URL: user/login Export rule as follow: { "rules_login" : { "LABEL" : "...


12

First create a Rules component for setting the status of a product. Go to Configuration -> Workflow -> Rules -> Components -> Add new component. Create an Action set. Give the component a suitable name, such as Set product status. Create a parameter of type Commerce Product, label Product, machine name product; and another of type Truth value, label Status, ...


12

In your rule add a data comparison called "view-mode" and set it to "Full content".


12

Why using .htaccess might not be an option There are situations where setting up a redirect in your .htaccess file may not be an option, such as: you are not allowed (= do not "have") edit access to your .htaccess file. your provider does not allow specific directives in .htaccess files (which you'd want to use). your Drupal site is running on IIS. you don'...


11

If you have access to your database, you can do it through there. You can see all the modules enabled with: SELECT name,status FROM system WHERE type='module' AND status='1'; You can disable a module by setting it's status to 0. UPDATE system SET status='0' WHERE name='module_name'; For more on uninstalling stuff via drupal's db.


10

Two things there: A. Define your custom order states with one of the Order info hooks. hook_commerce_order_state_info hook_commerce_order_status_info B. Create a commerce_order based VBO view and add an operation to change the order state. It won't be a button on each row, just a checkbox or radio button, but you can batch update that way. Alternatively, ...


10

Option 1: Use the Disable Messages module Use the Disable Messages module for this. Here is a quote from its project page: Gives a site owner options to disable specific messages shown to end users. The core drupal message system as offered by drupal_set_message is an excellent way for modules to send out messages to the end users. However not all drupal ...


9

So conceptual steps: Extract CSV file path from the node. Open CSV file, read fields from header. Read each row, convert the keys, save row using drupal_write_record(). Close the CSV. I'm not sure how the rules integration will work I'm assuming you can pass the node into it some how. So for step one assuming it's stored into $node and your field is ...


9

I found a module User Stats which integrates with Rules and provides tokens like [user:post-count] which can be used for numerical comparison. Hope this helps someone else.


9

You need to create the rule for Before saving content rather than After saving content. Before saving content has both the original node values and the new updated values which allows you to compare the values. After saving content only has the updated values, so you won't be able to see what the old values are.


9

The webform module comes with an option to send e-mails after submission. Check the webform e-mail tab when you are editing a webform


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']['...


8

You can do that with a rule like that: { "rules_after_login_redirect_to_news" : { "LABEL" : "After login redirect to news.", "PLUGIN" : "reaction rule", "WEIGHT" : "0", "REQUIRES" : [ "rules" ], "ON" : [ "user_login" ], "IF" : [ { "NOT text_matches" : { "text" : [ "site:current-page:path" ], "match" : "^user\...


8

The solution likely depends on the billing customer profile's address field using a split first and last name field instead of the combined "full name" field. I've noticed on my Commerce site that there appears to be a bug in Address Field (hope to fix soon) that prevents a full name field from being split up into first and last name fields or vise versa. ...


8

Found the solution. My rule was already sending an email but I could not see any token for the customer first and last name. Add a condition "Entity has field" > commerce_customer_billing Add an action "Fetch entity by id": Entity type > Value: Commerce Customer Profile Identifier > Data selector: commerce-order:commerce-customer-billing:profile-id ...


8

It has to be triggered when a particular role ("subscriber") has been removed. So we can use 2 conditions User has role(s), to check if he had the role before the edit, and that he doesn't have it after the edit : 1st condition : selector "account_unchanged", check the role "subscriber" (here test) 2nd condition : selector "account", check the same role, ...


7

If you choose the action "Set a data value" and a comment is visible to the action (e.g. because the triggering event is "After saving a new comment") then the data selector will let you choose comment:status which you can then choose to set to "Published" or "Unpublished", or (via a data selection) to another available value.


7

You need to add the order to the session, see commerce_checkout_access(). Something like this should work: $_SESSION['commerce_cart_orders'][] = $order->order_id; between saving the order and redirecting.


7

The OR and AND-groups takes all conditions inside of them with the chosen operator. Your: Condition 1: IT --OR ----Condition 2: FR Will be converted into ([Condition 1] AND ([Condition 2])). Try putting both Condition 1 and Condition 2 in the OR-group: --OR ----Condition 1: IT ----Condition 2: FR This should be converted into ([Condition 1] OR [...


7

Yes, you can define dynamic rules in a custom module. See hook_node_access Here's a sample implementation: /** * Implements hook_node_access(). */ function MYMODULE_node_access($node, $op, $account) { if ( // The $node argument can be either a $node object or a machine name of // node's content type. It is called multiple times during a page ...


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