get_records_sql($sql, array('%' . $search . '%', '%' . $search . '%')); // Format the users into a format expected by the user selector. $options = []; foreach ($users as $user) { $options[$user->id] = $user->firstname . ' ' . $user->lastname . ' (' . $user->email . ')'; } return array(get_string('users') => $options); } }