With users being entities in D7 I assumed the user type would would have built in "comment" option. That doesn't seem to be the case. I just want to allow users to leave comments on the user profile page. Is there a simple way to doing that?
-
Also there's modules drupal.org/project/user_profile_comments and drupal.org/project/reply that allows to attach commenting for user profiles– apostnikovCommented Oct 14, 2014 at 21:34
-
Dupliacated question, look at: [this answer][1] [1]: drupal.stackexchange.com/questions/19888/…– pinueveCommented Aug 7, 2015 at 20:20
-
There is now a User profile comments module, which appears to solve this very problem.– digitgopherCommented Mar 24, 2016 at 23:14
10 Answers
You can use Profile2, that attach node to user profile, so it can be commented and will look as commenting to user.
-
Can you please explain how to attach node to user profile. One user having doubt but he is not able to add comment. Here is question: drupal.stackexchange.com/questions/79945/… Commented Jul 23, 2013 at 4:22
I have not tried it, but the Reply module looks really good.
Reply is a D7 answer to entity comments. It is not intended to replace core comment module, more likely it supplements it's inability to work with entities other than node.
Reply is basically a fieldable entity with subject and body fields which are hardcoded into module and are not Field API fields. This is because it is the essence of reply/comment. The entity is fieldable so you can create a 'review' or whatever you like by attaching fields to it's bundles.
-
Yeah i think this is probably the future way to go, though the module itself needs quite some work to have the same kind of usuable feature-set of the core comment module. It definitive need some help Commented Feb 4, 2012 at 12:30
Currently in Drupal 7 core, the comment module is still coupled to node.module
. Comments are entities but can't be added to entities other than nodes.
You can see this issue to get the update: Decouple comment.module from node
I will encourage the use of statuses http://drupal.org/project/statuses for a "twitter-facebook" wall style. It's not a "comment" entity but it works pretty well.
I also looked the code, it is well written and has many hooks.
Statuses also integrates with: Views Activity Flag Rules Domain Mollom Notifications Messaging Pathauto Services Twitter Userpoints
If the use case is one where each user can only comment once (like a review for example), the best solution I've found is using the Flag Module. Version 7.3 of Flag is now fieldable. So you create an "add comment" flag and add a text field + whatever other fields you want to it. Then you can display the contents of the flags in a view. Very flexible, extendable and non-hack-y solution.
The way I ended up implementing comments on user profiles was to add a "guestbook" content type that has a user reference field.
When you look at someone's user profile you can click "sign guestbook" which links to "node/add/guestbook?edit[field_guestbook_userreference][und][uid]=user123".
The prepopulate module is used to prefill the username on the node add form with "user123" and I use css to hide that field. The guestbook has comments enabled to allow others to comment as well.
I use a view block to show the "guestbook" titles on the userprofile.
Inspired by @MotoTribe (similar question here), I solved it like this:
You'll need: views, panels, rules, entity reference and entity reference prepopulate modules.
Make a content type
user_comments
, remove body field (if you don't, users will have to input 2 fields: title and body). Comments will become node title (255 Maximum length). Add a entity reference fieldfield_user_reference_comments
.Make a USER view (name:
user_comments
), add relationship to "entity reference". Add contextual filter: User Uid > provide a default value -> User ID from Url.Inside view make 2 blocks (I did content panes).
- First block: add UID field, rewrite results:
<a class="" href="/node/add/user-comments?field_user_reference_comments=[uid]">Add comment</a>
. - Second block: add content title field using the relationship. Add more relations and fields as needed.
- First block: add UID field, rewrite results:
Add a new rule (import from here, make sure follow syntax explained above):
{ "rules_redirect_on_add_a_user_comment" : { "LABEL" : "redirect on add a user comment", "PLUGIN" : "reaction rule", "OWNER" : "rules", "TAGS" : [ "user account" ], "REQUIRES" : [ "rules" ], "ON" : { "node_insert--user_comments" : { "bundle" : "user_comments" }, "node_update--user_comments" : { "bundle" : "user_comments" } }, "DO" : [ { "redirect" : { "url" : "users\/[node:field_user_reference_comments]" } } ] } }
Enable from panels "user-view". Add user being viewed, add views First block, add views Second block.
Now you're done; it should work great. Build your view as complex as you need, add: fields, filters, sorts, etc. works perfect.
The user profile is essentially a view; you can hook into the view to include the comments.
-
that's if I use profile2? Otherwise where would the comments come from?– uweCommented Sep 19, 2011 at 19:14
create comment node with all fields. Among them one field must refer to the profile2 type(Using reference module). Then you can attach that node to profile2 using EVA module. If any better answer, let me know.
you can add a field collection item to your profile and then add arbitrary fields to it. so users can insert comment with it if you use field permision module and give all users the permision of inserting comment. it is works properly I've try it