Retrieving users from Database on to forms I have a webform with a select option type field. I need an authenticated user to view other available users in the website in this list. So, it needs to be dynamic by communicating with the database. What is the best way to do this?

Thanks in advance!
You have to use hook_webform_select_options_info() in your custom module.

I made my first module with that hook because i needed to achieve a similar thing but with people who were linked thanks to module relation. I show you what i did (i change the query to retrieve all users from the site, i'm not an expert in query). It was my first code, so it's not very optimize but it's work.

function my_module_webform_select_options_info() {
  $items['membres'] = array(
  'title' =&gt; t('Membres'), 
  'options callback' =&gt; 'webform_membres_options', 
  );
return $items;
}

function webform_membres_options($node)  {
  global $user;
  $store = array();

  $result = db_query("SELECT users.name AS users_name, users.uid AS uid, users.mail AS  users_mail
                      FROM {users} users
                      WHERE (( (users.status &lt;&gt; '0') ))");


 //Store mail|username in an array (good format for select options) 
 foreach ($result as $row) {
   $store[$row -&gt; users_mail] = $row -&gt; users_name;
 }
 //All users don't have relationship so we have to check the length of array            
 if (count($store &gt; 0)) {
   return $store;
 } 
     else {
   return false;
 }
 }


You'll see your list in Load a pre-built option list when you'll build your webform (after selecting "select options") Don't forget to put a default value for the select list.
After you'll see your list in the webform :