How to have separate private comments for nodes apart from the general comments?

Drupal Answers Asked by quest on February 6, 2021

I have a specific requirement.
Apart from the general comments which everyone can view or post for my custom node I also require private comments thread which will be shared only by the node created user and selected few.
Using the same comments form will not work as it will be viewed by all.
Any inputs on achieving this?


2 Answers

If you are up for a bit of code you can try the following approach,

Create a content type "private comments", it will have the title and body field that you need by default, you need to add a node reference field to the content type on which you want this private comments enabled. Now you need to create a block that will render the node add form for this content type. You can then enable this block where you want your private comments.

On the submit function, the title and body will be saved by Drupal, you need to add a submit handler so that the reference between your content type and comments is saved.

The advantage of creating a content type is you will get integration with views and you can then show your comments anywhere.

Answered by Kimi on February 6, 2021

For Drupal 7 see the Reply module. It lets you create your own set of "comments" attached to any Entities you want.

With some custom code you could limit the field to a specific user role or set of users. Be sure to read the README in the module.

Answered by tenken on February 6, 2021

Add your own answers!

Related Questions

Undefined function in module

0  Asked on December 19, 2021 by idjit


How to get group id from custom url

1  Asked on December 17, 2021 by leopathu


Some fields are not sorting properly in view

1  Asked on December 17, 2021 by weblink


Drush Hangs on wget but wget Works

1  Asked on December 14, 2021 by marshmellow1328


How to get menu title inside menu–main.html.twig file

1  Asked on December 14, 2021 by siddiq


hook_form_alter add field after submit button to exposed view

1  Asked on December 14, 2021 by user7355700


Images uploaded with CKeditor disappear after cron run

1  Asked on December 12, 2021 by alexander-kim


How have multiple instances of a Custom Block?

2  Asked on December 10, 2021 by jagmitg


Node view mode in page template suggestions

1  Asked on December 10, 2021 by sarah-c


How to sort translation under Translate tab?

1  Asked on December 10, 2021


Migration with default values in the yml file

1  Asked on December 10, 2021 by webuser57


menu_get_active_trail returns page not found

1  Asked on December 8, 2021 by jurgenr


hook_field_formatter_view does not get called

1  Asked on December 8, 2021 by alexei-rayu


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP