AJAX login without a plugin does not work. when add a action to function.php
You need to hook it later. add_action(‘template_redirect’ , ‘prevent_profile_access’); References: https://codex.wordpress.org/Plugin_API/Action_Reference https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect