vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Showing Different Stuff When Logged In Or Not...? (https://vborg.vbsupport.ru/showthread.php?t=28177)

SystemLogic 09-16-2001 05:03 AM

On the front page of a forum, how can I set something up so that it only shows if you are logged in? For example, a message shows up if you are unregistered or not logged in, and goes away when you are logged in.....what if I wanted something the other way around?

BobbiX 09-16-2001 08:14 AM

Well, here's how I do that ... I'm pretty sure all PHP freaks will know of a better way, but anyway :

Code:

<?
require("./global.php");

if ($bbuserinfo['userid']!=0) {
*code here what you want to happen when use is logged in*
} else {
*code here what you want to do when user isn't known*
}

When you want to display a login option for not logged in users which returns to the same page afterwards, you should add that stuff to the header of your page :

Code:

<?
header ("Pragma: no-cache");
header ("Cache-Control: no-cache, must-revalidate, max_age=0");
header ("Expires: 0");
?>

Keep in mind that this only works when the page you call glboal.php from is in the same directory as the global.php itself ... if not, you should just do a chmod (like 'chdir("/paths/to/your/frums");' ... just don't forget to jump back to the initial directory after you included the global.php then!

Like I said at the beginning, there might be thousands ways to do that better ... but hey, it works :)

Best regards,

Bobbi

SystemLogic 09-16-2001 03:02 PM

Well for unregistered users, there is a a variable called $unregwelcomemessage in the forumhome template. There is also a template called forumhome_unregmessage. What about setting something up in that matter, basically the same exact thing, just rather than unregmessage, a new one called like loggedin_message or something?

Admin 09-17-2001 12:31 PM

In index.php replace this:
PHP Code:

$unregwelcomemessage='';
if (
$bbuserinfo['userid']==0) {
  eval(
"\$unregwelcomemessage = \"".gettemplate('forumhome_unregmessage')."\";");


with
PHP Code:

$welcomemessage='';
if (
$bbuserinfo['userid']==0) {
  eval(
"\$welcomemessage = \"".gettemplate('forumhome_unregmessage')."\";");
} else 
  eval(
"\$welcomemessage = \"".gettemplate('forumhome_regmessage')."\";");


Now delete $unregwelcomemessage from your forumhome template and place $welcomemessage instead.
Also create a template named forumhome_regmessage and use it for messages for logged in users.

SystemLogic 09-18-2001 06:48 PM

Thanks, that worked perfectly. You made a little mistake in your code for anybody that would like to use this. You did this:

PHP Code:

$welcomemessage='';
if (
$bbuserinfo['userid']==0) {
  eval(
"\$welcomemessage = \"".gettemplate('forumhome_unregmessage')."\";");
} else 
  eval(
"\$welcomemessage = \"".gettemplate('forumhome_regmessage')."\";");


It should actually be:

PHP Code:

$welcomemessage='';
if (
$bbuserinfo['userid']==0) {
  eval(
"\$welcomemessage = \"".gettemplate('forumhome_unregmessage')."\";");
} else {
  eval(
"\$welcomemessage = \"".gettemplate('forumhome_regmessage')."\";");


You forgot the { after else, otherwise it gives a parse error.

Thanks again

Admin 09-19-2001 04:25 AM

Damn brackets... :rolleyes:


All times are GMT. The time now is 08:47 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01070 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete