In the core, the bottom input names are marked with the instance number, e.g. new_role
(top) and new_role2
(bottom). Here are two approaches to usefor a similar naming convensionconvention, namely course_section1
(top) and course_section2
(bottom):
function add_course_section_filter()
{
static $count =$instance= 0;
// Dropdown options
$options = '';
foreach( range( 1, 3 ) as $rng )
{
$options = sprintf(
'<option value="%1$d" %2$s>Section %1$d</option>',
$rng,
selected( $rng, get_selected_course_section(), 0 )
);
}
// Display dropdown with a different name for each instance
printf(
'<select name="%s" style="float:none;"><option value="0">%s</option>%s</select>',
'course_section' . ++$count++$instance,
__( 'Course Section...' ),
$options
);
// Button
printf (
'<input id="post-query-submit" type="submit" class="button" value="%s" name="">',
__( 'Filter' )
);
}
add_action( 'restrict_manage_users', 'add_course_section_filter' );
where we used the core function selected()
selected()
and the helper function: