Skip to content

Instantly share code, notes, and snippets.

@Jerl92
Created May 25, 2019 10:07
Show Gist options
  • Select an option

  • Save Jerl92/39edbd31f512f357c4c297e99cdec2fe to your computer and use it in GitHub Desktop.

Select an option

Save Jerl92/39edbd31f512f357c4c297e99cdec2fe to your computer and use it in GitHub Desktop.
Show a selectable list of users
<?php
$users = get_users( array( 'fields' => array( 'ID' ) ) );
$html[] .= "<select id='event-users' multiple>";
foreach($users as $user_id){
if ( get_current_user_id() != $user_id->ID ) {
$data = get_user_meta ( $user_id->ID );
$html[] .= "<option value='$user_id->ID'>";
$html[] .= $user_id->ID;
$html[] .= " - ";
$html[] .= $data['first_name'][0];
$html[] .= " ";
$html[] .= $data['last_name'][0];
$html[] .= "</option>";
}
}
$html[] .= "</select>";
$arr = implode("", $html);
echo $arr;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment