我想window.localStorage.clear
在登录和注销后清除。我已在 functions.php 中添加了此代码,但它不起作用。我该如何克服呢?
add_action(' wp_logout ',' auto_redirect_external_after_logout ');
function auto_redirect_external_after_logout(){
echo '<script>window.localStorage.clear();</script>';
exit();
}
function do_anything() {
echo '<script>window.localStorage.clear();</script>';
}
add_action('wp_login', 'do_anything');