voogah Posted April 3, 2010 Share Posted April 3, 2010 I know this has to do with Wordpress as well, but I have not had much luck with Wordpress Forums like I have this one. I have a custom page that works with the Wordpress P2 theme. I need to get the global variable $current_id. I have used the following code, and it works great in IE but doesn't show anything in Safari or FireFox. There are no errors, but it is blank. So it is not retrieving the Global variable. <?php require_once '../wp-config.php'; global $current_user; get_currentuserinfo(); $member_online = $user_ID; ?> Any suggestions!! Thanks! Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 4, 2010 Share Posted April 4, 2010 global $current_user; Might help if $current_user was defined that we can see. However.. why don't you try this? get_currentuserinfo($current_user); function get_currentuserinfo($current_user){ function stuff entgiodsgiisdiofjdiosgjsio } This way you wont need a global. If that don't work, then I can easily say it's not getting the value of $current_user Quote Link to comment Share on other sites More sharing options...
voogah Posted April 5, 2010 Author Share Posted April 5, 2010 Thanks for your help TeddyKiller! Unfortunately that does not help either! I believe the $current_user global is set in the Wordpress pluggable.php file. Here is the code: (again I believe....somewhat new to this) function wp_set_current_user($id, $name = '') { global $current_user; if ( isset($current_user) && ($id == $current_user->ID) ) return $current_user; $current_user = new WP_User($id, $name); setup_userdata($current_user->ID); do_action('set_current_user'); return $current_user; } endif; if ( !function_exists('wp_get_current_user') ) : Again, the code I used in first post works in IE great!! It is just Safari and FireFox that it doesn't?? The same is true if I try to call the Wordpress Login Cookies. Works in IE but not Safari or Firefox. It just doesn't seem to find it like I have not connected to Wordpress somehow! Any help is appreciated! Thanks! Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 5, 2010 Share Posted April 5, 2010 <?php require_once '../wp-config.php'; global $current_user; get_currentuserinfo(); $member_online = $user_ID; ?> Try an echo. <?php require_once '../wp-config.php'; echo $current_user; exit; //global $current_user; And for this.. //get_currentuserinfo(); commenting out temporarily //$member_online = $user_ID; same for this ?> Does that give you values, for all browsers? Quote Link to comment Share on other sites More sharing options...
voogah Posted April 5, 2010 Author Share Posted April 5, 2010 Thanks, But no, the echo prints the value just fine in IE but a blank screen in Safari! It just isn't finding the value in Safari or Firefox and I don't understand why! Quote Link to comment Share on other sites More sharing options...
voogah Posted April 5, 2010 Author Share Posted April 5, 2010 I've even used the following code which seems to be more direct, but it still does not show for Safari or Firefox! <?php require './wp-config.php'; function wp_get_current_user() { global $current_user; get_currentuserinfo(); return $current_user; } $member_online = $user_ID; echo $member_online; ?> $user_ID is a string that is part of $current_user. Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 5, 2010 Share Posted April 5, 2010 The problem is where $current_user; is defined then. Work your way backwards. Try some troubleshooting until you find out the actual.. stop for it. $current_user could not actually be the stop, the function to define it may be, or even any of the variables in that function could be, or where those variabels inside that function to define $curent_user are defined. And so on. Being a third party script, it is pretty much impossible. Not many of us will actually install the exact same wordpress version as you and try to duplicate the problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.