when you want interaction between client side and server side you should use ajax . i think this [Link][1] will be very helpful to you :) [1]: https://wordpress.stackexchange.com/questions/69814/check-if-user-is-logged-in-using-jquery