Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
  #1  
Old 09-16-2001, 05:03 AM
SystemLogic SystemLogic is offline
 
Join Date: Nov 2001
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #2  
Old 09-16-2001, 08:14 AM
BobbiX BobbiX is offline
 
Join Date: Oct 2001
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #3  
Old 09-16-2001, 03:02 PM
SystemLogic SystemLogic is offline
 
Join Date: Nov 2001
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #4  
Old 09-17-2001, 12:31 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 09-18-2001, 06:48 PM
SystemLogic SystemLogic is offline
 
Join Date: Nov 2001
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 09-19-2001, 04:25 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Damn brackets...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:16 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04461 seconds
  • Memory Usage 2,214KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete