Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Niko Belger Posted February 17, 2018 Posted February 17, 2018 Hello, I'm trying to fetch the current logged in member with $member = \IPS\Member::loggedIn(); However, I always get the following exception (regardless if logged in or not) 'LOCATION_UNKNOWN' in /forum/system/Session/Session.php:60 Stack trace: #0 /forum/system/Member/Member.php(145): IPS\_Session::i() #1 /forum/hwid/API/API.php(14): IPS\_Member::loggedIn() #2 {main} any suggestions?
Aiwa Posted February 17, 2018 Posted February 17, 2018 You need to provide a bit more context. Based on that error, it appears this is a script outside the IPS framework...If that's the case, it doesn't know if you're on the front end or AdminCP. /* Require the init.php file from the Community Suite root directory */ require '/path/to/suite/init.php'; /* Initiate the session to verify who this user is */ \IPS\Session\Front::i(); $member = \IPS\Member::loggedIn();
Niko Belger Posted February 17, 2018 Author Posted February 17, 2018 I use the same way in another script, however there I do not get anny error. What exactly do you mean by running outisde the framework <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require_once('/srv/public_html/forum/init.php'); //Check permissions \IPS\Session\Front::i(); try { $member = \IPS\Member::loggedIn(); } catch( \RuntimeException $ex ) { echo $ex; } print_r($member);
Ryan Ashbrook Posted February 17, 2018 Posted February 17, 2018 Try using \IPS\Dispatcher\External::i(); instead of \IPS\Session\Front::i();
Niko Belger Posted February 17, 2018 Author Posted February 17, 2018 4 hours ago, Ryan Ashbrook said: Try using \IPS\Dispatcher\External::i(); instead of \IPS\Session\Front::i(); yup, that worked! Thank you very much
Recommended Posts
Archived
This topic is now archived and is closed to further replies.