Firefox PHP

User status based on number of posts

Posted by Mandingo 
Re: User status based on number of posts
July 30, 2004 06:00PM
put some output with print/echo in your function to see if its called.
you set postlabel and want to use mod_status in the template? use the same variable.


Thomas Seifert
Re: User status based on number of posts
July 31, 2004 04:23AM
Right. Now we've got -

hook: read|phorum_mod_status

title: Status Module

desc: List the status of user depending on volume of posts.

===================================================

<?php

function phorum_mod_status($data)
{
$PHORUM = $GLOBALS["PHORUM"];

if(isset($PHORUM["mod_status"])){

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!";

}

$data[$message]["postlabel"] = $message;
}
}

return $data;
}


?>

===================================================

with -

{IF MESSAGES->user_id true}{LANG->Status}:&nbsp;{MESSAGES->postlabel}{/IF}</p></td>

in the 'read.tpl' template.

I put

'echo $data;'

}

after 'return $data; but I get a parse error when I do that.

Re: User status based on number of posts
July 31, 2004 04:27AM
> after 'return $data; but I get a parse error when I do that.

put it in BEFORE return $data ... with return the function ends.


Thomas Seifert
Re: User status based on number of posts
July 31, 2004 04:35AM
O.K. I did that.

It still doesn't work. I just get the word 'array' appear in top left of my read page.
Re: User status based on number of posts
July 31, 2004 04:37AM
Right, I fixed the 'array' word appearing. I now have -

<?php

function phorum_mod_status($data)
{
$PHORUM = $GLOBALS["PHORUM"];

if(isset($PHORUM["mod_status"])){

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!";

}

$data[$posts]["postlabel"] = $message;

echo $data;
}
}


return $data;
}


?>

But still no joy.

:-(
Re: User status based on number of posts
July 31, 2004 04:38AM
thats a start ;).
also you are still messing variables.

change
foreach ($messages as $message) {
to
foreach ($messages as $message_id=>$message) {

where do you get $user_id from?

$user = phorum_user_get($user_id, false);
should probably be
$user = phorum_user_get($message['user_id'], false);


$data[$message]["postlabel"] = $message;
should be
$data[$message_id]["postlabel"] = $message;


Thomas Seifert
Re: User status based on number of posts
July 31, 2004 04:40AM
oh another thing ... where do you have $messages from?

foreach ($messages as $message) {

should get (with the post above)

foreach ($data as $message_id=>$message) {





Thomas Seifert
Re: User status based on number of posts
July 31, 2004 04:47AM
Right. Thanks. Sooooooo...now we have -

status.php -

===================================================

<?php

function phorum_mod_status($data)
{
$PHORUM = $GLOBALS["PHORUM"];

if(isset($PHORUM["mod_status"])){

foreach ($data as $message_id=>$message) {
$user = phorum_user_get($message['user_id'], false);
$posts = $user["posts"];
if ($posts > 100) {
$message["postlabel"] = "You've posted a lot!";
}
else {
$message["postlabel"] = "You newbie!";

}

$data[$message_id]["postlabel"] = $message;
echo $data;
}
}


return $data;
}


?>

===================================================


info.txt -

===================================================

hook: read|phorum_mod_status

title: Status Module

desc: List the status of user depending on volume of posts.

===================================================

and in 'read.tpl' -

===================================================

{IF MESSAGES->user_id true}{LANG->Status}:&nbsp;{MESSAGES->postlabel}{/IF}

===================================================

and.................


it's still not working! :-)





Edited 1 time(s). Last edit at 07/31/2004 04:49AM by Mandingo.
Re: User status based on number of posts
July 31, 2004 05:14AM
yes its still wrong but from the look of this thread it looks like we could have done this alone.

you set the whole message as postlabel, so either set just a string as postlabel in the result or just set the whole message again (not only as postlabel).


Thomas Seifert
Re: User status based on number of posts
July 31, 2004 05:36AM
Totally lost with this now.

You're saying something like this -


$string =$data[$message_id]["postlabel"] = $message;
echo $data["postlabel"];

should be in place of -

$data[$message_id]["postlabel"] = $message;
echo $data;


???

===================================================

I'm giving up on this one myself, hopefully someone else with a bit more knowledge will pick up on it because it would be a nice feature but I'm finding it very frustrating.



Edited 1 time(s). Last edit at 07/31/2004 05:42AM by Mandingo.
Sorry, only registered users may post in this forum.

Click here to login