Hi, i want to enable comments on all the pages on my website but want to to set it up in such a way that only logged in users can comment. I have figured out how to hide comments from users that are not logged in but that does not help me since i want everyone to see the comments but only want logged in users to comment. Pls help
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
You can require login using PageCommentInterface::set_comments_require_login(true);
Thanks alot for the help
Hi, sorry, I must be a real newbie here. Can you please explain this solution in a little more detail? This is exactly what I am looking to do - with one exception. I have a page type HiddenForm (as opposed to page type Page) and only want comments to require login on HiddenForm pages, not on all pages. Thanks in advance!
Hi there,
To enable it you will add the line to your mysite/config.php file
So in the mysite/config.php file you will add the following
// Set page comments to require login //
PageCommentInterface::set_comments_require_login(true);
Thank you for your help. Unfortunately, that applied it to the whole site, not just the page type HiddenForm. Placing it in .php file for that file type did the trick however, which was awesome! But i also needed the form to be different and the single comment interface to be different, so i copied the two PageComment* .php files, replaced Page with HiddenForm in the names of the copies, searched in the files for PageComment and replaced each instance with HiddenFormComment. Also had to edit one of the core Sapphire files to allow for HiddenFormComments as well as PageComments. Of course i had to copy the two PageComment* .ss files and edit them the same way as i did the .php files, and then edited the .php file that defines the fields to only include the fields I want in the HiddenFormComments and adjusted the *singlecomment.ss file to look the way i want. Everything works well!! The only thing I still need to figure out is how i am going to get the CMS to recognize HiddenFormComments so i can edit them. Moderation isn't necessary as only logged-in users can post, anyway, and removing them is easily done from the webpage itself. But in case one ever needs to be edited, i would like to be able to see them in the CMS, as well. Any suggestions on that would be most appreciated; suppose it would have been easier to make a HiddenFormComments module after all of this!
Also, anyone out there know if it is possible to enable html tags inside comments?