Hi There -

Am trying to make a select menu from buddylist names.

Buddylist has the wonderful function: buddylist_get_buddies() which, when you print_r, gives you the array below, with the indices being the uid of the user.

What I'd really like to do is have a select list, with the usernames in the pulldown part, and when it's selected, both the username and the uid get added to the $content variable as an array. I've never heard of this, so I don't know if it is possible. If I can't have this, I'll settle for just name/name pair. I can get this by creating an array of the names and surrounding it with:

<?php
  '#options' => drupal_map_assoc($options),
?>

I'm very interested in various strategies for thinking about the other way of doing it.

buddylist_get_buddies() gives you this. 
Array
(

    [4] => Array
        (
            [uid] => 4
            [name] => janie
            [mail] => janie@delicious.local
            [online] => 0
        )

    [5] => Array
        (
            [uid] => 5
            [name] => auntiemay
            [mail] => auntiemay@delicious.local
            [online] => 0
        )

    [6] => Array
        (
            [uid] => 6
            [name] => clarissa
            [mail] => clarissa@delicious.local
            [online] => 0
        )
)

Comments

davedelong’s picture

You could rebuild the array yourself...

$buddies = buddylist_get_buddies();
$options = array();
foreach($buddies as $uid => $info) {
  $options[$uid] = $info['name'];
}

And then use:

  '#options' => $options,