Topic: PunBB 1.3 - Defining $forum_user['prev_url'] from outside the forum

How to define $forum_user['prev_url'] properly from outside the forum? What I'm after is to redirect the user back to the page that is outside the forum (but still in the same domain of course) where the user was before logging in.

Is there a dedicated method/function to do that already or does it require a hack? Tried everything and nothing worked. Using set_default_user() I got the prev_url variable to update correctly outside the forum too but as soon as I go to login the variable is replaced and after login I get redirected to forum index again.

Re: PunBB 1.3 - Defining $forum_user['prev_url'] from outside the forum

I'm not sure exactly what you're asking, but if you're just asking to go back a page, you can do that in JavaScript:
<a href="javascript: history.go(-1)">Back</a>

3 (edited by Spewed 2008-08-31 20:34)

Re: PunBB 1.3 - Defining $forum_user['prev_url'] from outside the forum

Thanks for the reply, nerdtopia, but that's not what I'm asking for. I'm talking about the PunBB user variable that holds the previous page URL where the user is redirected to after logging in.

I have pages "outside" the PunBB forum that uses PunBB data thru integration. I want user to get redirected back to the custom page where the user clicked login link (login link redirects to PunBB login page) when a user browses these custom pages, the same way as the user is redirected back to the topic/post after logging in at PunBB forum area.

The issue is currently that when a user comes to the login page from a custom page, the user gets redirected to forum index instead of the custom page where the user came from in real.

Edit: Just realized I posted this to a wrong forum, Integration would have been the correct place for this. A kindly moderator will move this there, will ya? cool

4 (edited by Spewed 2008-09-02 22:02)

Re: PunBB 1.3 - Defining $forum_user['prev_url'] from outside the forum

This post lead me to the right track, still not getting this to work. I believe set_default_user() is the answer but why I can't get it to update the prev_url column on the online table when I call it from my custom pages? hmm

It does update the $forum_user['prev_url'] array but doesn't update the online table in the database, what am I missing here?

My site structure is the following if it makes a difference:
/forum/ (here's PunBB)
/section1/ (here's a custom page that queries PunBB db located in the forum dir)
/section2/ (here's another custom page that queries PunBB db located in the forum dir)
etc.

Using set_default_user() I got the prev_url variable to update correctly outside the forum too but as soon as I go to login the variable is replaced and after login I get redirected to forum index again.

Have to correct that, the issue is that only the array gets updated as descriped above, not the online table in the db so after I locate to the login.php the hidden redirect_url is fetched from the db table which has the old referer/prev_url.

Edit: The code I'm using on the custom pages is here:

// Integrate PunBB
define('FORUM_ROOT', '../forum/');
require FORUM_ROOT.'include/common.php';

// Set prev url for redirecting properly after logging in
set_default_user();

5 (edited by Spewed 2008-09-03 20:33)

Re: PunBB 1.3 - Defining $forum_user['prev_url'] from outside the forum

Okies, solved. To get the prev_url to work properly also forum footer.php is required. After adding this, you can use for instance a direct login link in your own custom pages that leads to PunBB login page and you'll get redirected to that custom page after login. smile

require FORUM_ROOT.'footer.php';