How to set state programmatically

Created on 28 May 2014, over 10 years ago
Updated 22 August 2023, about 1 year ago

I am trying very hard to figure out how to set the state of nodes during a views bulk operation custom action I have created. I suppose I could manually set the ->state_flow->current and do a node save for each item, but I am not sure that this will then fire my "After a State Flow Event occurs" event to cause my rules to be obeyed.

What method/function would I use in this 7.x-2.x-dev branch to set the state of the node so that this state flow event will be fired?

πŸ’¬ Support request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States crashtest_ Richland, WA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ͺπŸ‡ΈSpain juampynr

    For reference, in Workbench Moderation 7.x-2.x-dev, this worked to me to unpublish a node:

    
    $node = node_load(218821);
    $node->status = NODE_NOT_PUBLISHED;
    $node->event = 'to_unpublished';
    node_save($node);
    
Production build 0.71.5 2024