Advertisement:

code for users post count?

Aloittaja estes, marraskuu 20, 2013, 09:26:23 IP

« edellinen - seuraava »

estes

this is related to my other post.  i have another portion of my site (nonforum) that checks if a forum user is logged in.  if they are logged in, it gives them access to certain pages.

in the future i'd like to restrict this to users with 25 or more posts only.  should i just pull this data from the database or is it stored in a session variable?

Arantor

That depends mostly on how you're getting the current users data, as you may or may not already have it available to you... so how *are* you getting it? Straight SSI.php include or something more exotic?
Holder of controversial views, all of which my own.


estes

im pretty sure the snippet of code in the one file is just this:

<?php
  $title = "Guest";
  if(isset($_COOKIE["SMFCookie424"])) {
    $title = "Member";
  }
?>

Arantor

Do I really need to point out how insecure that actually is?
Holder of controversial views, all of which my own.


estes

Lainaus käyttäjältä: Arantor - marraskuu 20, 2013, 11:31:12 IP
Do I really need to point out how insecure that actually is?

the data protected isn't anything major :)

and the average user that visits my site isn't going to bother to hack through to get access when all they have to do is create an acct.  if they do happen to know how to get through, they can have access :)

estes

guess i scared you away :)

is there an easy way to pull the post count without fancy code?

if you have an easy solution that you feel more comfortable with, that's not a problem...i can update the code.

All Colours Sam

Best and simplest way would be to include SMF's SSI.php file, that file gives you access to pretty much everything.

You can query the DB to get the current user's post count, can't remember if the var $user_info holds that info or not, $user_info is an array of, well, user info :P the current user whos viewing that page.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

IchBin™

Lainaus käyttäjältä: Suki - marraskuu 22, 2013, 08:43:04 APcan't remember if the var $user_info holds that info or not, $user_info is an array of, well, user info :P the current user whos viewing that page.

Yes it does. Was wondering why someone did say that. $user_info['posts'] if I remember right.
IchBin™        TinyPortal

estes


Advertisement: