User status based on number of posts
Posted by Mandingo
User status based on number of posts July 30, 2004 04:50AM |
Registered: 21 years ago Posts: 109 |
Hi,
I got this idea from a message board I saw.
At the moment, I have this in read.tpl to show the number of posts by a user in their messages -
{IF MESSAGES->user_id true}{LANG->Posts}: {MESSAGES->user->posts}{/IF}
What I'd like to do is have it so that anyone with less than say 50 posts has the word 'new poster' next to their total or someone with say 5000 posts has 'legendary poster' or something like that. :-D
i suppose I'd have to edit read.php to achieve that?
I got this idea from a message board I saw.
At the moment, I have this in read.tpl to show the number of posts by a user in their messages -
{IF MESSAGES->user_id true}{LANG->Posts}: {MESSAGES->user->posts}{/IF}
What I'd like to do is have it so that anyone with less than say 50 posts has the word 'new poster' next to their total or someone with say 5000 posts has 'legendary poster' or something like that. :-D
i suppose I'd have to edit read.php to achieve that?
Re: User status based on number of posts July 30, 2004 07:06AM |
Moderator Registered: 19 years ago Posts: 634 |
Re: User status based on number of posts July 30, 2004 09:43AM |
Registered: 21 years ago Posts: 109 |
Re: User status based on number of posts July 30, 2004 09:59AM |
Moderator Registered: 19 years ago Posts: 634 |
Just off the top of my head quickly (I can look at it more later when I'm at home), but my Avatar module does something similar. I believe down at the bottom in the last function is when it works with reading posts.
Its using the "read" hook, which gets called when somebody is reading a message (or a series of messages in flat mode). For each message if an avatar is set, it adds a variable to that messages data saying so.
In your case, you could use very similar code. Something like this should do the trick:
Your template would then simply have to print out {MESSAGE->postlabel} in the appropriate place.
Its using the "read" hook, which gets called when somebody is reading a message (or a series of messages in flat mode). For each message if an avatar is set, it adds a variable to that messages data saying so.
In your case, you could use very similar code. Something like this should do the trick:
foreach ($messages as $message) { $user = phorum_user_get($user_id, false); $posts = $user["posts"]; (I think that is the variable name anyway) if ($posts > 100) { $message["postlabel"] = "You've posted a lot!"; } else { $message["postlabel"] = "You newbie!"; } }
Your template would then simply have to print out {MESSAGE->postlabel} in the appropriate place.
Re: User status based on number of posts July 30, 2004 12:02PM |
Registered: 21 years ago Posts: 109 |
Re: User status based on number of posts July 30, 2004 12:40PM |
Moderator Registered: 19 years ago Posts: 634 |
Re: User status based on number of posts July 30, 2004 05:03PM |
Registered: 21 years ago Posts: 109 |
O.K. so if I do a file called 'info.txt' and put in it -
hook: read|mod_status
title: Status Module
desc: List the status of user depending on volume of posts.
and a 'status.php' with -
<?php
if(!defined("PHORUM_ADMIN")) return;
foreach ($messages as $message) {
$user = phorum_user_get($user_id, false);
$posts = $user["posts"];
if ($posts > 100) {
$message["postlabel"] = "You've posted a lot!";
}
else {
$message["postlabel"] = "You newbie!";
}
}
?>
am I going in the right direction?
It's showing up in admin and I can turn it on there, but nothing shows in the message body.
Sorry I'm a TOTAL newbie to mods.
I THINK I need something like -
function phorum_mod_status ($messages)
in there somewhere?
Edited 2 time(s). Last edit at 07/30/2004 05:15PM by Mandingo.
hook: read|mod_status
title: Status Module
desc: List the status of user depending on volume of posts.
and a 'status.php' with -
<?php
if(!defined("PHORUM_ADMIN")) return;
foreach ($messages as $message) {
$user = phorum_user_get($user_id, false);
$posts = $user["posts"];
if ($posts > 100) {
$message["postlabel"] = "You've posted a lot!";
}
else {
$message["postlabel"] = "You newbie!";
}
}
?>
am I going in the right direction?
It's showing up in admin and I can turn it on there, but nothing shows in the message body.
Sorry I'm a TOTAL newbie to mods.
I THINK I need something like -
function phorum_mod_status ($messages)
in there somewhere?
Edited 2 time(s). Last edit at 07/30/2004 05:15PM by Mandingo.
Re: User status based on number of posts July 30, 2004 05:23PM |
Admin Registered: 20 years ago Posts: 9,240 |
Re: User status based on number of posts July 30, 2004 05:28PM |
Registered: 21 years ago Posts: 109 |
Re: User status based on number of posts July 30, 2004 05:51PM |
Registered: 21 years ago Posts: 109 |
O.k. here's what I have -
<b>info.txt</b>
hook: read|phorum_mod_status
title: Status Module
desc: List the status of user depending on volume of posts.
==================================================
<b>status.php</b>
<?php
function phorum_mod_status($message)
{
$PHORUM = $GLOBALS["PHORUM"];
foreach ($messages as $message) {
$user = phorum_user_get($user_id, false);
$posts = $user["posts"];
if ($posts > 100) {
$message["postlabel"] = "You've posted a lot!";
}
else {
$message["postlabel"] = "You newbie!";
}
}
return $message;
}
?>
==================================================
Then I edit 'read.tpl' to include this -
{IF MESSAGES->user_id true}{LANG->Status}: {MESSAGES->mod_status}{/IF}
And....nothing happens :-(
<b>info.txt</b>
hook: read|phorum_mod_status
title: Status Module
desc: List the status of user depending on volume of posts.
==================================================
<b>status.php</b>
<?php
function phorum_mod_status($message)
{
$PHORUM = $GLOBALS["PHORUM"];
foreach ($messages as $message) {
$user = phorum_user_get($user_id, false);
$posts = $user["posts"];
if ($posts > 100) {
$message["postlabel"] = "You've posted a lot!";
}
else {
$message["postlabel"] = "You newbie!";
}
}
return $message;
}
?>
==================================================
Then I edit 'read.tpl' to include this -
{IF MESSAGES->user_id true}{LANG->Status}: {MESSAGES->mod_status}{/IF}
And....nothing happens :-(
Sorry, only registered users may post in this forum.