Zlatko.Lakisic
Member
Posted 2 years ago #
Ok so the situation is i have a program called livezilla which opens up in a new window, in that new window i have a jquery call to a php page called wp-blog-header.php which contains the following code
<?php
require('../wp-blog-header.php');
if (is_user_logged_in())
{
global $current_user;
get_currentuserinfo();
echo "a|1|".$current_user->user_firstname."|".$current_user->user_lastname."|".$current_user->user_email;
}
else
{
echo "a|0";
}
?>
Now i call this with a jquery function called .get() which reads the page contents and fills a javascript variable which i then split into an array. Everything works fine but each time, even tho i am logged in to wordpress it returns "a|0" which means that it is not logged in. Can anyone tell me why this is happening and how can i fix it? This only happens when calling the php page via jquery from the popup window.
Thanks in advance!
Move the following above the if and see if it works:
global $current_user;
get_currentuserinfo();
If that doesn't work put print_r(get_defined_vars()); right after the require and see what information you have to work with.
Zlatko.Lakisic
Member
Posted 2 years ago #
ok i put the `global $current_user;
get_currentuserinfo();` before the if statement and now when i visit it in the browser it works, but when its called via the jquery .get() ajax function it says that im not logged on. wierd. the get_definded_vars() gives me a lot of info, what are you looking for?
Hey, that's progress.
the get_definded_vars() gives me a lot of info, what are you looking for?
Yes, it does. I wasn't looking for anything in particular. I was hoping there would be something related to users in there. What does get_defined_vars give you when you request via jQuery.get?
Zlatko.Lakisic
Member
Posted 2 years ago #
well i decided not to go the ajax way and just to set a cookie and retrieve it with jquery later, but when opening the page in the popup window its not reading the cookie, im not sure why, what am i missing?
Zlatko.Lakisic
Member
Posted 2 years ago #
I solved it! The main reason is that window.open not only opens a new window but a new session so it ignores the cookies set in the parent window. What I did is I encrypted the values with php and passed them in a uri paramater and then I used jquery to decrypt the value and use it that way.