The module content moderation has been activated and a custom workflow added to a content type. On editing content, when selecting a content moderation state then clicking on save, I would like to programmatically save that value in a variable.
$mod
in that code doesn’t display the latest values for moderation state chosen on update.
I wonder if what I get is the default revision value (as configured for a state, Révision par défaut Quand le contenu atteint cet état il devrait devenir la révision par défaut; ceci est implicite pour les états publiés.) but it is definitely not the latest revision value.
function my_hook_entity_update(DrupalCoreEntityEntityInterface $entity) { if ($entity->getEntityTypeId() !== 'node') { return; } $content_id = $entity->id(); $content = DrupalnodeEntityNode::load($content_id); $mod=$content->get('moderation_state')->getValue(); var_dump($mod); die(); }
How do I get the latest value of content moderation on node update?
Sponsored by SupremePR