6 December
Programmatically add comment drupal 8
Published On: Mon, 12/06/2021 - 16:10
Add this line in head
use Drupal\comment\Entity\Comment;
These are following code format which can use to add comment through custom code in Drupal 8 or 9
$values = [ 'entity_type' => 'node', // required. 'entity_id' => $nid, // required. 'field_name' => 'comment', // required. 'uid' => $uid, // required. 'comment_type' => 'comment', // required. '…