Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

restrict comments to logged in users: solved


Reply


6 Posts   785 Views

Avatar
Optic Blaze

Community Member, 165 Posts

2 November 2011 at 11:32am

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

Avatar
Willr

Forum Moderator, 5513 Posts

4 November 2011 at 6:41pm

You can require login using PageCommentInterface::set_comments_require_login(true);

Avatar
Optic Blaze

Community Member, 165 Posts

5 November 2011 at 7:55am

Thanks alot for the help

Avatar
restar

Community Member, 2 Posts

7 February 2012 at 4:22pm

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!

Avatar
Optic Blaze

Community Member, 165 Posts

7 February 2012 at 10:12pm

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);

Avatar
restar

Community Member, 2 Posts

8 February 2012 at 8:36am

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?