I need to remove all of the options in a dropdown that don't have a specific value. Here's my code: `
<select name="worker"> <option value="0">John Doe</option> <option value="5">Jim Smith</option> <option value="6">Jane Doe</option> </select> `
I'm in wordpress, and basically need to say, "If the current user is 5 (Jim Smith), then only show him in the dropdown. Any help would be greatly appreciated.
Here is the php code that generates the dropdown:
/* Workers */ $workers = $wpdb->get_results("SELECT * FROM " . $this->workers_table . " " ); $html .= '<label>'; $html .= '<span class="title">'.__('Provider', 'appointments'). '</span>'; $html .= '<select name="worker">'; // Always add an "Our staff" field $html .= '<option value="0">'. __('No specific provider', 'appointments') . '</option>'; if ( $workers ) { foreach ( $workers as $worker ) { if ( $app->worker == $worker->ID ) { $sel = ' selected="selected"'; } else $sel = ''; $html .= '<option value="'.$worker->ID.'"'.$sel.'>'. $this->get_worker_name( $worker->ID, false ) . '</option>'; } } $html .= '</select>'; $html .= '</label>';