TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 22, 2024, 03:56:44 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,197
  • Total Topics: 21,221
  • Online today: 226
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 159
  • Total: 159

block permission according to message count.

Started by deniz, April 19, 2006, 06:15:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ianedres

This will add 1 query to your page, and retrieve the current number of posts stored in the members table. (i.e. whatever SMF reports in stats)...

Obviously, you will need to exclude it from guests in permissions when making the php block or article; did not code for that since TP can handle that.

global $db_prefix, $context;

$query = db_query("
SELECT posts FROM {$db_prefix}members
WHERE ID_MEMBER = {$context['user']['id']}
", __FILE__, __LINE__);

list($num_posts) = ($query = mysql_fetch_row($query));

if($num_posts < 1)
{
echo 'Display message for members with less than 1 post.';
}
else
{
echo 'Display message for members with 1 or more posts.';
}

Sineksekiz

Sorry I couldn't quite get which file to add this. Is it gonna go in to Themes/default/TPortalBlocks.template.php or Source/TPortalAdmin.php.

Thank you.

IchBin

Ianedres, actually if you look at the $user_info array in includes $user_info['posts']. You could then check the that count just like I specified earlier in this topic.

Ianedres

Well, a big 'duh' for me. I got stuck on the $context array and did not use, as you suggested, $user_info...

Definitely would make more sense to use the $user_info, if nothing else, to save a query and code as well.

$myFoo took a big hit on that one...

Sineksekiz

Are you still speaking English? : D

:tries to come between to professionals

G6Cad

They are just fooing eatch other again, it will be good in th next post they make   ;D

IchBin

global $user_info;
if ($user_info['posts'] < 100)
echo 'this for users with a post count less than 100';


This is the basics of what it would look like. This isn't something that you can put into TP to make blocks work  like you are wanting. In fact, Bloc has said in the past that he never had plans to add post count groups into TP. The code above is just something that you can add in a custom block to only display things to a user with a specified post count.

Sineksekiz

#17
Oh I get it. No I didn't. Oh yeah here it is again. So if I understand you correctly If I open a phpblock and insert this code in the begining of it and change the count like however I like it should work.

Please tell me that I got it. Even if you had to lie tell me please....

Like:


global $user_info;
if ($user_info['posts'] < 100)
echo 'For user less then 100 count';
else
echo 'For user has more';


right?

By the way what does Bloc has against to this kind of member groups?

IchBin

That looks right to me. And I'm not lying either. lol I'm not sure why Bloc did that. Probably because of what is involved to add that to all of the TP features.

Sineksekiz

#19
This works just great.

Thank you guys. You managed to save my stinky hide again. : D