Adding some capabilities checks to the AJAX functions.