PDA

View Full Version : Display custom message to guests


11-02-2000, 03:43 PM
I am trying to display a custom message to guests on the forum I help run...so when they come in, instead of saying "Welcome back..." it will say a customisable message that could be defined from the templates.
I was planning to put some php in the templates to do this but now I remember that you can only parse php code in the header/footer.
Has this ever been done before, or perhaps someone could point me in the right direction?

Thanks in advance! :)

11-02-2000, 05:42 PM
Are you talking about the "welcometext" template?

11-02-2000, 06:36 PM
Sorry I didn't explain this quite well enough :)
I would like a different message to be displayed to unregistered users to that showed to normal registered users.
So eg a normal user would get "Welcome back $username. You last visited...." but a guest would get "Welcome to eDevBoards forums. Please register at this link. "
I presume cookies would be needed for this.

Thanks! :)

11-02-2000, 08:14 PM
Basically you will have to replace the template "welcometext" with PHP code within index.php.

Your code will then have to check if they are a valid user by checking the $bbuserid variable against the database. If they are a valid user then use the default welcometext string. If not use the string you wish for the quests.

I.E.

if ($bbuserid) {

...*Check Database Here *...

$welcometext = "Welcome Back " . $username;
}
else {
$welcometext = "Your a guest go register please!.!.!"
}

11-03-2000, 04:45 AM
Thanks a lot! :)
Wayne, recognise me? I'm James from SitePoint :)

11-03-2000, 04:57 AM
I've adapted it slightly to use templates, so if anyone actually wants the hack let me know and I will release it :)
But its hardly a hack, only a few lines of code :D

11-03-2000, 02:26 PM
I've adapted it slightly to use templates, so if anyone actually wants the hack let me know and I will release it

I'd love to see it!

11-04-2000, 08:04 PM
OK here it is: :D
Tested on 1.1.3 and 1.1.4
Demo location: http://www.eDevBoards.com (only if you haven't registered -- otherwise it wont show up :))


Setup Instructions:

Open up the forum control panel and add a template called "guestmsg". In it type the message you want displayed to unregistered users, along with any formatting. I have used the <smallfont> tags to make it fit better on the page.

Open global.php into your favorite text editor and find the following line:
eval("\$fivelinks = \"".gettemplate("fivelinks")."\";");

Above it, insert the following code:

if ($bbuserid == "0") {
eval("\$guestmsg = \"".gettemplate("guestmsg")."\";");
}


Go into your forum control panel again, and find the place you want the guest message to show up. I have mine at the bottom of the fivelinks template. Type "$guestmsg" in the right place.


Not much of a hack, but anyway :D