Comments on user profile pages

lunas - June 10, 2006 - 14:34

Morning, I'm trying to allow users to leave comments on user profile pages. Anyone know how to go about getting the comment form to show up on my modified user_profile.tpl.php page? And also will need any comments left to be able to show up as well. Finally, if a comment is left I want to be able to allow that user to moderate it if necessary (at least be able to delete offensive ones). Can someone point me in the right direction? You can check out a profile at http://www.how-to-box.com/boxing/user/1230 for an example - want the profile to appear then underneath the ability to leave comments.

Figured it out

lunas - June 10, 2006 - 16:01

Figured it out...extracted the function from the guestbook module that displays a form/guestbook entries on the regular profile pages - removed the function portion of the function and added an output line - now works good.

Why don't you post the code

rivena - June 10, 2006 - 19:18

Why don't you post the code here, maybe someone else is looking for the same thing? :)

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 16,000 card scans and counting!
-----------------------------------------------------------

Here's the Code

lunas - June 22, 2006 - 20:58

This is what I put into my user_profile.tpl.php file. You need the guestbook module installed and then this code makes the form/comments show up on a user's profile page.

<?php
$uid
= arg(1);
  if (
_guestbook_access('administer', $uid) && is_numeric($op_id)) {
    switch (
$op) {
      case
"delete":
      
$y = guestbook_delete_entry_confirm($uid, $op_id);
      case
'comment':
       
$comment_entry = $op_id;
        break;
    }
  }

 
// Fetch guestbook entries
 
$userid4 = arg(1);
 
$limit = variable_get('guestbook_entries_per_page', 20);
 
$result = pager_query(
   
"SELECT g.*, u1.name, u1.data, u1.picture, u2.name as commentby
    FROM {guestbook} g
    LEFT JOIN {users} u1 ON g.author = u1.uid
    LEFT JOIN {users} u2 ON g.commentauthor = u2.uid
    WHERE g.recipient = $userid4
    ORDER BY g.created DESC"
,
   
$limit, 0, "SELECT COUNT(*) FROM {guestbook} WHERE recipient = %d", $userid4);
 
$entries = array();
  while (
$entry = db_fetch_array($result)) {
   
$entries[] = $entry;
  }

 
$output = theme('guestbook', $userid4, $entries, $comment_entry, $limit);

  print
$output;
?>

Cheers.

thanks

Julius - July 15, 2006 - 10:55

Thanks. Is this the way to make all sorts of snippets? abstract the code from the module, loose the function, etc.

I still have so much to learn about the coding of Drupal.

$userid4 = arg(1);
Who knew you could just do that?

Do you think it would be possible to make it that you only view the latest 5 and a 'next' link to see all.
Update: so that's just in the setting of guestbook. So I 'fixed' it :)

Well for now this is great at least. So thanks again.

Tring to allow comments on

kweisblatt - August 15, 2006 - 02:47

Tring to allow comments on profile pages.....

I used profile over ride with user_profile.tpl.php and everything looks good, but I want to allow comments. I ried the aboove and enabled the guestbook and entered the above code into my user_profile.tpl.php file, but it made my page blank so I must be doing something wrong within the code above. I copied and pasted it in the file, so I am guessing I either put it in the wrong place or had a tag I didn't need. Also want to add more photos to profile page as well. Any help is greatly appreciated!

Kris

Current project: www.cribfax.com

I'm also wanting more pictures to profile

Vaughan - August 18, 2006 - 10:16

Hi kweisblatt (and everyone else too),

I'm also looking at uploading more pictures to the profiles. ideally I want to enable another picture as an optional background to the user profile page.

Any help would be great.

Thanks

Vaughan

Thanks

Vaughan - August 18, 2006 - 10:12

Thanks a lot for this, it is 99% of what I'm looking for (just a bit of tweaking with layout)

Being new to Drupal, having this to start with is a great help.

Just one question to anyone that can help, is there a way of submitting a comment, then gong back to the "profile" page without staying on the guestbook page. I'm probably trying to take the easy way out, and will look at this as well on my side. If I find something, i'll post it here.

Regards

Vaughan

Sounds good. I also enabled

kweisblatt - August 18, 2006 - 14:50

Sounds good. I also enabled the guestbook and switched back to the default profile through drupal so the links would show. I am terribly disappointed that I can't customize the profile page :(

Anyone know if it's possible to customize the profile without overiding with user_profile.tpl.php?

~~~~~~~~~~~~~~~~
Kris
Current project: www.cribfax.com

Edit the guestbook module

Slimz - September 14, 2006 - 00:23

I wanted the same thing. Edit the guestbook.module at this line
and replace 'guestbook/' to this. It's in the function guestbook_form_entry_submit section.

line 407: return 'user/'. $uid;

perfect

sinker - September 26, 2006 - 18:02

that little line makes all the difference--points the finished post back to the profile page instead of the guestbook. Totally changes the user experience!

Another aproach...

filip_tc - August 23, 2006 - 22:33

I'd be greatfull if you'd check out my issue @ http://drupal.org/node/80310, especially lunas for being the author of the snipplet.

Thx in advance,
Phil

Need to remove user pict from comments

Slimz - September 9, 2006 - 01:06

Hello,

Actually I have two things I would like to do. The script works fine on my user_profile page but I would like to remove the user picture in post. I'm looking at the guestbook module now and haven't seen where to format the comments. Any suggestions?

Also, when you access a profile page it outputs the Add guestbook entry with the message form and a send button. When you add your entry and click send, it goes to the add guestbook entry page - can I just have a link that will goto the entry page and not the message field? Just a Add Comment button that will take you to the guestbook entry page.

cool script - thanks for the post!

This is great

sinker - September 26, 2006 - 18:01

This is fantastic--does exactly what I was hoping for (that change in line 407 is crucial for usability).

However, has anyone noticed that if you click on a users' name in the guestbook, it points you back to their guestbook, NOT to their profile? Anyone have an inkling on how to change that so it's pointing to the profile page instead? Thanks!

 
 

Drupal is a registered trademark of Dries Buytaert.