Permalink

Hi Kosta,

Thanks a lot for the tutorial! I've been trying to make this feature work for a while and your tutorial has got me almost there. I have a site where users can add up to 5 custom equipment configurations and give them each a custom name. The name is input through a CCK field in their profile. When they make a tech support request through Webform, I used your code to generate a custom query showing each of their five configurations as select list options.

Everything works fine until I view the webform the user has submitted and the result is my uid's configuration (with the appropriate key value, no less). I think there's a problem with the handling of the global user variable in this case, but I'm very new to PHP and SQL, so if you could help me out, I'd really appreciate it! Here's my code:

function webform_custom_webform_select_options_info() {
$items = array();

if (function_exists('_webform_custom_get_custom_options')) {
$items['story-nodes'] = array(
'title' => t('Custom options'),
'options callback' => '_webform_custom_get_custom_options',
);
}
return $items;
}

function _webform_custom_get_custom_options() {
global $user;
$sql ="SELECT `field_configname2_value` , `field_configname3_value` , `field_configname4_value` , `field_configname5_value` , `field_configname_value`
FROM `content_type_config_system` , `node` , `users`
WHERE Node.uid = Users.uid
AND ".$user->uid." = Users.uid
AND Node.nid = Content_type_config_system.nid";

$res = db_query($sql);
while($row = db_fetch_array($res)){
$rows = array($row['field_configname_value'], $row['field_configname2_value'], $row['field_configname3_value'], $row['field_configname4_value'], $row['field_configname5_value']);
}
return $rows;
}

?>

Thanks again!

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.