Questions tagged as ['comments']

When a comment is submitted, no confirmation message is shown and I would like to achieve this. I want to show the following message.
Your comment has been added for review and approval.
I tried this code.
function mymod_form_alter(&$form, FormStateInterface $form_state, $form_id) {
else if ($form_id == 'comment_comment_form') {
$form['actions']['submit']['#value'] = "your comment has been ...

I am overwriting the CommentBulkForm
class in my module.
namespace Drupal\mymod\Plugin\views\field;
use Drupal\comment\Plugin\views\field\CommentBulkForm;
/**
* Defines a custom comment operations bulk form element.
*
* @ViewsField("custom_comment_bulk_form")
*/
class CustomCommentBulkForm extends CommentBulkForm {
/**
* {@inheritdoc}
*/
protected function emptySelectedMessage() { ...

I have a comments page set up and when I devel the page for a specific comment I see the getcommentedentity method.
I am trying to get the commented entity details using the below code in my VBO action file:
public function execute(ContentEntityInterface $entity = NULL) {
$comment = $entity->get('comment_body')->getValue();
$commentid = $entity->get('cid')->getValue();
$va ...
I want to add comments to user profiles. I added the comments in user profile under Configuration > People > Account settings, but when I add the field, the option to select the comment type is showing empty. What is the correct way to allow other users to give comments on user profiles?
I want to show the comment title linked to the comment permalink. This is the content of the comment.html.twig file.
<div{{ content_attributes.addClass('comment__content') }}>
{% if title %}
{{ title_prefix }}
<h3{{ title_attributes }}><a href="#comment-{{comment.id}}">{{ title | render | striptags}}</a></h3>
{{ title_suffix }}
{% endif %}
...
On my Drupal 9 site, I created 2 types of comments:
- comment_type_a
- comment_type_b
When I go for permissions, there are only permissions for all comments in general.
How do I modify the permissions assigned to a comment type?
I want for comment_type_a only admin role can comment.
I want for comment_type_b all roles to be able to comment.