This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Drupal 9 replacement for hook_comment_insert

I have a D7 module where I use hook_comment_insert($comment) to check whether the comment created is published or not:

 if ($comment->status->value == 0) {
  // Do stuff.
}

It looks like this hook is gone in D9. What do I use instead?

Hide revision checkbox but revision must be created

Hello,

I am trying to find solution how to hide check box in "EDIT content" but I need create revision.

My users have to edit content, but I need to know what they did. If I hide "checkBox" where is "create new revision" then no revision was created.

I tried "hide revision module" but if user did not see this "checkbox choice" then new revision was not created.

I tried last drupal version 9.1.5 - no luck. Version 8.2 and older is not working on my machine. I found some topic with this problem but without solved.

Please, could you help me?

BR

How to disable a resource with json api programmatically

Hi team,

I've created a resource with json api,
but i would like to know if there is some way to enable and disable programmatically
screenshot

Could you please help me?
Regards
Mario

Drupal commerce- Add discount rule for the cart

Hello everyone and sorry for my english.

I would like to add a statement to my e-shop. I would like something like "Order has products and quantity" but instead of products, i would like "product category and quantity". For example i have 4 products in my cart and the 2 of them are from the same category "books", i would like for example 10% discount only to these two products. I tried "product category:books" and "'total item in order' equals to 2" but refers to all products in cart and not to the specific category "books".

I would like your help.

form alter

In a Movimenti content type, I have several fields one of these is an entity references, linked to an Anagrafica Dipendente data content type.
The field is enhanced by a function. In form_alter I need to take a field of the Anagrafica Dipendente.
I saw the array of the field and was thinking of using this code
     $id = $form['field_dipendente']['widget'][0]['target_id']['#default_value']['id'];
But the error returns to me
 Error: Cannot use object of type Drupal\node\Entity\Node

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions