I'm using a Wordpress plugin to create users for my site and I need to check if a user if logged in and then execute something in a jquery function. The plugin states they have public functions set up for such things. I'm not sure if I have this set up correctly, whether the user is logged in or out it is coming up "loggedout". The public function is in my functions.php file of my theme and is :
function loggedin() {
$FEUP = new FEUP_User;
if ($FEUP->Is_Logged_In()) {
echo "loggedin";
} else {
echo "loggedout";
}
}
my jquery function is :
var user = "<?php loggedin(); ?>";
if(user == "loggedin") {
console.log("user is logged in");
}else {
console.log("user is logged out");
}
This is a screenshot from the makers of the plugin as to how to implement the public function to see if the user is logged in: