Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Is it possible to get the node ID of the node that will be created?

Is it possible to get the node ID of the node that will be created?
, by

Trying to pass some information to third party API, every time a new node is created.

So far I have managed to identify the node insert/create when a node is created in hook_node_presave(). Done it by using empty($node->id()).

Now I want to anticipate what the node ID will be once the node is saved. Is it possible to get the node ID before the node is created?

1 answer
votes: 389
Answer

You can use hook_ENTITY_TYPE_insert which is called after the node has been saved.

Function description:

This hook runs once the entity has been stored. Note that hook implementations may not alter the stored entity data.