I was wondering if anyone knew how to setup the buddylist module so there is automaticaly (an admin) user on their friendlist from when they register? Kinda like myspace has Tom as a friend for every new user.

Possible?

Comments

robertdouglass’s picture

For anyone interested in implementing this, here is a suggestion how you would do it:

  1. Make a setting on admin/settings/buddylist that explained this option and (using an AJAX user search field) let a user be specified.
  2. Implement buddylist_user in such a way that (assuming #1) every newly created user inserted the appropriate uid and buddy uid into the buddylist table.
apt94jesse’s picture

I got my functionality to work like this. I added these lines in the page.tpl.php:

$buddycount = db_query('SELECT COUNT(*) FROM {buddylist} WHERE uid = %d', $GLOBALS['user']->uid);
  $buddyobject=db_result($buddycount, $row=0);
  if ($buddyobject=='0') {
  db_query('INSERT INTO {buddylist} (received, uid, buddy, timestamp) VALUES (1, %d, %d, %d)' , $GLOBALS['user']->uid , '1' , time());
  }

As you can see, I query the buddylist table, count the entries where the current user has buddies. If that count is 0, then it executes the insert query adding the default buddy. This way, whenever a new user logs in for the first time, their buddy count is of course 0, so it adds the buddy into the table.

rkn-dupe’s picture

Sounds like a good idea. I will try it out sometime, if it works for everyone i reckon it should be part of buddylist because its a good feature!

apt94jesse’s picture

This thread follows my progress, should you be interested. I doubt it would be possible to be part of the buddylist.module since it requires adding some lines of code into the core user.module.

http://drupal.org/node/90437

fago’s picture

Status: Active » Closed (duplicate)