Vbulletin: Check if users are logged in

Discussion in 'vBulletin' started by Cypherus, Jun 6, 2007.

  1. #1
    Hi there,

    I run a vbulletin forum, and I've made a couple of tools for the users to use. I was wondering if there are any functions/classes/snipples for me to add to this page with tools, that checks if the users are logged in to the board? I don't want unregistred users to keep using my tools.

    Also, if it's possible to tell the difference from normal users, admins, what group they belong to etc etc, that would be great!
     
    Cypherus, Jun 6, 2007 IP
  2. BamaStangGuy

    BamaStangGuy Notable Member

    Messages:
    955
    Likes Received:
    51
    Best Answers:
    1
    Trophy Points:
    245
    #2
    This checks to see if the user is a member:
    <if condition="$show['member']"></if>
    Code (markup):
    This checks to see if the visitor is in the defined usergroups:
    <if condition="in_array($bbuserinfo[usergroupid], array(1,2))"></if>
    Code (markup):
     
    BamaStangGuy, Jun 6, 2007 IP
  3. Cypherus

    Cypherus Peon

    Messages:
    1,551
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That's in the templates. I'm talking about standalone sites I've made, that I just want to include to the board..
     
    Cypherus, Jun 6, 2007 IP
  4. Cypherus

    Cypherus Peon

    Messages:
    1,551
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm bumping this thread.

    Take a look at Earners forum. They have built alot of extra sites. Anyone know how they can build sites OUTSIDE VB, but still have them connected to the VB database?
     
    Cypherus, Jun 6, 2007 IP
  5. BamaStangGuy

    BamaStangGuy Notable Member

    Messages:
    955
    Likes Received:
    51
    Best Answers:
    1
    Trophy Points:
    245
  6. Cypherus

    Cypherus Peon

    Messages:
    1,551
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It must be possible in some way to do it outside those stupid VB templates?
     
    Cypherus, Jun 6, 2007 IP
  7. YourSiteKindaBlows

    YourSiteKindaBlows Peon

    Messages:
    166
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You have to write the file yourself...

    http://www.earnersforum.com/tools.php


    tools.php is a separate file that was uploaded to the site.


    Find out the code you need, create a text file, upload the text file and then change it to a php file.


    That's about it...the answer doesn't get easier than that.

    Then all you do is customize it to your needs...
     
    YourSiteKindaBlows, Jun 7, 2007 IP
  8. Cypherus

    Cypherus Peon

    Messages:
    1,551
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You must think I'm stupid or something?

    Of course I know that I have the make the file and upload it! I'm asking if there is a class or something I can include, to connect to the VB database! "Find the code you need".. That's what I'm trying to do..
     
    Cypherus, Jun 7, 2007 IP
  9. BamaStangGuy

    BamaStangGuy Notable Member

    Messages:
    955
    Likes Received:
    51
    Best Answers:
    1
    Trophy Points:
    245
    #9
    Well if you'd look at the damn link I gave you it tells you the files you need to include to use vBulletin's classes and functions.
     
    BamaStangGuy, Jun 7, 2007 IP
  10. Cypherus

    Cypherus Peon

    Messages:
    1,551
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #10
    So far this is the only code snip I've found that does the job.. but cookies are to unsecure:

    
    <?php
    $logged = ($user = $HTTP_COOKIE_VARS["bbuserid"]);
    
    if ($logged >= "1") {
    ?>
    
    your page code goes here.
    
    <?php
    }
    if ($logged < "1") {
    echo "<div align=center>You must be a registered user of the forums.<br><br>";
    echo "Please click <a href=http://www.accordtuner.com?#login><i><b>here</b></i></a> ";
    echo "to login first...<br><br>Or click <a href=http://board.accordtuner.com/register.php?&action=signup><i>";
    echo "<b>here</b></i></a> to register with our forums.</div>";
    }
    ?>
    
    Code (markup):
     
    Cypherus, Jun 13, 2007 IP
  11. mickmel

    mickmel Peon

    Messages:
    384
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #11
    This is easy. You'll love me. :) I do it on all of my sites.

    Somewhere near the top of your file, include your global.php, like this:

    include_once("/home/yoursite/public_html/forums/global.php");
    Code (markup):
    Then, when you want their info, it's done like this:

    $currentuserid = $vbulletin->userinfo['userid'];
    $currentusername = $vbulletin->userinfo['userid'];
    etc...
    Code (markup):
    Want to know if they're in a particular membergroup?
    (membergroup 9 is a custom one on one of my sites)

    if(ereg('9', $vbulletin->userinfo['membergroupids'])) { ...
    Code (markup):
    Basically, anything from the "user" table can be pulled this way, even custom columns that you added.

    At the top of my sites I usually grab the currentuserid and then just:

    if ($currentuserid == 0) {
       echo("Please login or register, blah blah blah");
    } else {
       echo("Welcome back to the site, " . $currentusername);
    }
    Code (markup):
    Is that what you were after?
     
    mickmel, Jun 25, 2007 IP
    Cypherus likes this.
  12. Cypherus

    Cypherus Peon

    Messages:
    1,551
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Yeah, that got things moving ! Green rep for you:)
     
    Cypherus, Jun 26, 2007 IP
  13. Colleen

    Colleen Illustrious Member

    Messages:
    6,777
    Likes Received:
    725
    Best Answers:
    1
    Trophy Points:
    430
    #13
    Cool, this may come in handy, thanks for posting the code mickmel!
     
    Colleen, Jun 26, 2007 IP
  14. mickmel

    mickmel Peon

    Messages:
    384
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #14
    No problem. I literally use this on all of my sites. I can show ads to different usergroups on the main site, allow downloads based on their vB status, etc. It's quite powerful.

    The problem now is that every time I start a new site I pretty much need to purchase another vB license. It's just too easy to let vB handle all of the user management that I can't do without it!
     
    mickmel, Jun 27, 2007 IP
  15. Cypherus

    Cypherus Peon

    Messages:
    1,551
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Hehe.. if the sites makes revenue that shouldn't be a big problem :b
     
    Cypherus, Jul 5, 2007 IP