Firefox PHP

Does user registration support "redir" functionality?

Posted by Sean Phelan 
Does user registration support "redir" functionality?
November 06, 2008 11:50PM
Folks,

I have a nice inline login set up on the non-phorum part of my site - using the redirect logic in the login page, the user is taken right back to where they were before logging in.

My next question is ... for the new user, if I send them to register.php, is there any redirect equivalent to get them back to a specific URL after registration is complete?

------------------------
Sean Phelan
Sites By Sequoia - Web Marketing ... The Experts at Building Your Success Online
Re: Does user registration support "redir" functionality?
November 07, 2008 12:07AM
There is no such equivalent for the register page. But it is not hard to override. A simple one file module should do the trick. Here an untested example. Cut and paste to mods/mod_register_redirect.php in your Phorum dir and enable the module from the admin->Modules page.

Language: PHP
<?php   /* phorum module info hook: after_register|mod_register_redirect_after_register title: Redirect after Registration desc: This module redirects the user to a custom page after registering. */   function mod_register_redirect_after_register($user) { global $PHORUM; $PHORUM["DATA"]["URL"]["REDIRECT"] = ';http://www.example.com/page.html';; return $user; }   ?>

This will still show the message box. Another module could be used to do a direct redirect to your custom page.

Language: PHP
<?php   /* phorum module info hook: page_register|mod_register_redirect_page_register hook: after_register|mod_register_redirect_after_register title: Redirect after Registration desc: This module redirects the user to a custom page after registering. priority: run hook after_register after * */   function mod_register_redirect_page_register() { // Buffer output on the register page to prevent "headers already // sent" errors from PHP. ob_start(); }   function mod_register_redirect_after_register($user) { phorum_redirect_by_url(';http://www.example.com/page.html';); }   ?>

Both examples were extensively *not* tested, but I think they should be okay like this.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Does user registration support "redir" functionality?
November 07, 2008 05:21PM
Maurice,

Thanks for the sample, it looks pretty straight-forward.

I'll ask another newbie question ... what's the mechanism for saving session-specific data from page to page?

My thinking is that we could set a session value for the redirect URL, send the user to register.php, and then redirect using that URL - if no special URL defined, don't do a special redirect.

I guess I'm looking for the phorum equivalent of :
$_SESSION['redirect_url'] = '[domain.dom];

Thanks!

------------------------
Sean Phelan
Sites By Sequoia - Web Marketing ... The Experts at Building Your Success Online
Re: Does user registration support "redir" functionality?
November 07, 2008 05:38PM
there is no session in phorum but I guess you can simply use the php sessions.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Does user registration support "redir" functionality?
November 07, 2008 05:40PM
Really? Phorum doesn't store anything from page to page w/out permanently tying it to a user ?

------------------------
Sean Phelan
Sites By Sequoia - Web Marketing ... The Experts at Building Your Success Online
Re: Does user registration support "redir" functionality?
November 07, 2008 05:42PM
no, it doesn't. no need for that.
thats what post / get variables are for.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Does user registration support "redir" functionality?
November 07, 2008 07:01PM
And the data that has to be saved in a non-volatile manner is stored in the user table (like settings). Phorum has sessions implemented, but does not use PHP's standard sessions, because we do not like them. Sessions aren't magic. Sessions are simply blobs of data that are tied to a cookie that is stored in the user's browser.

The closest thing to PHP sessions, would be the use of phorum_api_user_save_settings() and the accompanying function phorum_api_user_get_setting().

The best way to store data with a user, is by creating custom profile fields. More on that can be found in the developer documentation about writing modules.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login