vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How to check in sidebar (forum blocks) if user is logged in? (https://vborg.vbsupport.ru/showthread.php?t=231693)

wman 12-30-2009 04:51 PM

How to check in sidebar (forum blocks) if user is logged in?
 
How can I check in the forum blocks that are displayed in the new sidebar whether a user is logged in, and display different content accordingly?

I tried the old...

Code:

// IF THE USER IS LOGGED IN
if ($bbuserinfo[userid])
{
    // CODE TO EXECUTE IF THE USER IS LOGGED IN
}
else
{
    // CODE FOR GUESTS
}

but that doesn't seem to work! Please help!

Lynne 12-30-2009 05:16 PM

in php, you use $vbulletin->userinfo, not $bbuserinfo. And, in the blocks it *may* be vB::$vbulletin->userinfo.

wman 12-31-2009 06:12 PM

Thanks - the following worked:

Code:

if (vB::$vbulletin->userinfo[userid])
{
        echo "logged in";
}
else
{
        echo "not logged in";
}

But the text is displayed at the top of the page, before any other output, instead of in the sidebar. I assume the "echo" is the culprit; do I have to add the text to some output variable instead?

Lynne 12-31-2009 07:55 PM

echo is the culprit. Look at the template the output is going to and the name of the variable you should be using is in there (I can't remember it - it might be $output, but may be something else).

To find the template to modify, do this - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code.

wman 12-31-2009 08:16 PM

The template is block_html and in that template I found the following variable: {vb:raw content}

I was not sure how to modify that variable though. Then I found this, and it seems to work:

Code:

if (vB::$vbulletin->userinfo[userid])
{
        $my_output = "you are logged in";
        return $my_output;
}
else
{
        $my_output = "you are not logged in";
        return $my_output;
}



All times are GMT. The time now is 07:05 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.00959 seconds
  • Memory Usage 1,716KB
  • 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
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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