This project is read-only.

Add custom field to comment part?

Topics: Customizing Orchard
Sep 16, 2015 at 12:39 AM
The real problem I am trying to solve is that I want users to be able to quickly and easily leave a comment (which I can do with Orchard comments module), but I want to prevent the user from skewing the results of a comment session by logging in under many different identities to make their comments.

I thought that one way to do this would be to record their IP address as a hidden field. Then when we analyze the comments, we can check for one user acting like many users.

I'm using this javascript tool to do grab the IP address:, and it is easy enough to use jquery to populate a hidden field with the results--I just need a field in the comment part where I can put the IP address.

Orchard comments has a default field called SiteName (Url) that enables users to enter their web address. I was going to re-purpose this field by turning it to "hidden" and sticking the IP address value in there. The problem with this is that Orchard validates the SiteName (Url) field and won't accept an IP address (x.x.x.x). I can't find where or how this field gets validated.

Can someone tell me how to remove this validation so that SiteName accepts an IP address?

Also, is there a better way to solve my fundamental problem without making the user authenticate?
Sep 16, 2015 at 8:19 AM
I think your best option would be to create a custom part for that, something like a CommentIpValidationPart with an ip property. This way you can query easily by the part's property instead of the field's value to view existing comments, and you can use the handler's events to intercept and do the ip validation.
Sep 16, 2015 at 5:40 PM
Thanks, Sandberg. Would creating that part and including it in the Comment content type also show the part in the Admin interface when I view comments, or would that take some additional work?
Sep 16, 2015 at 5:48 PM
If you create a Content Part then it would be displayed too, as it would involve creating the UI that is rendered on Display and on Edition.
Sep 16, 2015 at 5:52 PM
Thanks, Sebastienros. I have never created a part before. Will this link take me from start to finish, or is there additional information I'll need?
Sep 16, 2015 at 5:54 PM