user_session_restore doesn't seem to be working
Posted by shwonkbc
user_session_restore doesn't seem to be working September 01, 2009 11:04PM |
Registered: 15 years ago Posts: 3 |
Hi Phorum!
I'm having a little trouble with one of your hooks, user_session_restore.
Basically, I already have a log in system on my site, and would like for my users not to have to log in twice to use the board. Reading through the hooks, I found out the way to do this is through user_session_restore. Here's my code:
function phorum_mod_booze_user_session_restore($sessions) {
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$ident = $auth->getIdentity();
if($ident->role == 'member')
{
$user_id = (int)$ident->user_id;
}
}
if(!$user_id)
{
$user_id = false;
}
$sessions[PHORUM_SESSION_SHORT_TERM] = $user_id;
$sessions[PHORUM_SESSION_LONG_TERM] = $user_id;
return $sessions;
}
Basically it checks my auth, and if they're logged in, it sets $user_id to the user_id. I have checked with var_dump, and it is successfully doing this. (SHORT_TERM = 2, LONG_TERM = 2, ADMIN = null). I know I have added the module correctly, because editing code inside of the module has repercussions.
I have tried
$user = phorum_api_user_get($user_id);
if (empty($user)) {
trigger_error("User with user_id $user_id does not yet exist in Phorum!", E_USER_ERROR);,
and it does get the correct user when I var_dump that too, so i know I'm doing everything right.
However, it's not working. Even when I know i've made $sessions correctly, it will not allow my users to post. When I try to let them it says "Sorry, only registered users may post in this forum. " Do you know what could be causing this? It's very frustrating. Thanks!
I'm having a little trouble with one of your hooks, user_session_restore.
Basically, I already have a log in system on my site, and would like for my users not to have to log in twice to use the board. Reading through the hooks, I found out the way to do this is through user_session_restore. Here's my code:
function phorum_mod_booze_user_session_restore($sessions) {
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$ident = $auth->getIdentity();
if($ident->role == 'member')
{
$user_id = (int)$ident->user_id;
}
}
if(!$user_id)
{
$user_id = false;
}
$sessions[PHORUM_SESSION_SHORT_TERM] = $user_id;
$sessions[PHORUM_SESSION_LONG_TERM] = $user_id;
return $sessions;
}
Basically it checks my auth, and if they're logged in, it sets $user_id to the user_id. I have checked with var_dump, and it is successfully doing this. (SHORT_TERM = 2, LONG_TERM = 2, ADMIN = null). I know I have added the module correctly, because editing code inside of the module has repercussions.
I have tried
$user = phorum_api_user_get($user_id);
if (empty($user)) {
trigger_error("User with user_id $user_id does not yet exist in Phorum!", E_USER_ERROR);,
and it does get the correct user when I var_dump that too, so i know I'm doing everything right.
However, it's not working. Even when I know i've made $sessions correctly, it will not allow my users to post. When I try to let them it says "Sorry, only registered users may post in this forum. " Do you know what could be causing this? It's very frustrating. Thanks!
September 02, 2009 12:50AM |
Admin Registered: 20 years ago Posts: 8,532 |
I am afraid you will have to trace some of the code in include/api/user.php regarding this hook. Based on what I see here, the hook should work and the integration should be functional.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Maurice Makaay
Phorum Development Team



Re: user_session_restore doesn't seem to be working September 02, 2009 10:49AM |
Registered: 15 years ago Posts: 3 |
September 02, 2009 11:03AM |
Admin Registered: 20 years ago Posts: 8,532 |
Best place to start: function phorum_api_user_session_restore() in include/api/user.php
But before you do so, one very obvious option popped up in my head. Please check if you have used active = 1 for the users that you created in the Phorum users database table.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
But before you do so, one very obvious option popped up in my head. Please check if you have used active = 1 for the users that you created in the Phorum users database table.
Maurice Makaay
Phorum Development Team



Re: user_session_restore doesn't seem to be working September 02, 2009 11:14AM |
Registered: 15 years ago Posts: 3 |
September 02, 2009 11:35AM |
Admin Registered: 20 years ago Posts: 8,532 |
You had already been so thorough, that it made me forget the obvious ;-) Have fun with it!
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Maurice Makaay
Phorum Development Team



Sorry, only registered users may post in this forum.