I want to create an Autocomplete function in WordPress. I want a search field from where username can be searched. I am using following JQuery UI.
<label>Users</label>
<input type="text" name="user_name" id="user-name" />
<?php
$get_arr_user = array('John', 'Rogers', 'Paul', 'Amanda', 'Peter');
?>
<script>
jQuery(document).ready(function($) {
var availableTags = <?php echo json_encode($get_arr_user); ?>;
$( "#user-name" ).autocomplete({
source: availableTags
});
});
</script>
My problem is that I am not able to get the list of Usernames in this format – array('John', 'Rogers', 'Paul', 'Amanda', 'Peter');
How do I get that?