11

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?

10 Answers 10

8

You can use Profile2, that attach node to user profile, so it can be commented and will look as commenting to user.

7

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 – Daniel Wehner Feb 4 '12 at 12:30
5

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

2

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

2

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.

  • Excellent idea. Works like a charm in my case. – Rana Prathap Dec 30 '14 at 8:15
1

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.

1

Inspired by @MotoTribe (similar question here), I solved it like this:

You'll need: views, panels, rules, entity reference and entity reference prepopulate modules.

  1. 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 field field_user_reference_comments.

  2. 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.

  3. 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.
  4. 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]" } }
        ]
      }
    }
    
  5. Enable from panels "user-view". Add user being viewed, add views First block, add views Second block.

  6. Now you're done; it should work great. Build your view as complex as you need, add: fields, filters, sorts, etc. works perfect.

0

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? – uwe Sep 19 '11 at 19:14
0

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.