The goal is to reuse some part of code to login and logout user in ajax with or without reload page .
I can't call the content of php file ajax_user.php inside wordpress template directory from my plugin and it wp_ajax function (to login and logout user).
I tried these functions inside my wp_ajax function handle_user_login():
$resumeaccount = get_template_part( 'ajax_user') ;
$resumeaccount = include get_template_directory() . '/ajax_user.php' ;
My content inside ajax_user.php :
<?php echo'<div id="isconnecteddisplaylogout"><p> Connected</p><form id="atv_user_logout" method="post" action="atv_user_logout"><button id="disconnect" type="submit" class="logout">Sign out?></button></form></div>';?>
I tried without echo , without singlequote and wihtout <?php for this ajax_user.php file. Nothing change
Using include get_template_directory()
json data return object : [1]
the content of ajax_user.php work well if I insert it directly inside variable $resumeaccount : without to try to call php file from template directory
I can't define if my issue come from syntaxe or function get_template_directory().