miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Condition to check if currently logged user posted in a topic

 
Author tom322
Active Member
#1 | Posted: 5 Jan 2015 00:59 
New Year, new question ; ).

Currently in order to check if a given member is the author of the currently viewed topic, the condition is:

if($action=='vthread' and $user_id==$topicData[2]) echo 'I started this topic';...

// if TRUE the user_id has started this topic
Is there a similar (hopefully simple) way to check if user posted (at least one message) in the currently viewed topic?

Thank you.

Author kuopassa
Partaker
#2 | Posted: 5 Jan 2015 01:24 
Should probably do some kind of array search. This is just an idea, not a working solution. Perhaps PHP function in_array could help:

// Somehow ID's of users who've posted in current topic should be fetched. (How? No idea.)
$message_ids = array();

// Then compare if there's one or more matches.
if (in_array($user_id,$message_ids)) { echo 'yes'; }

Author tom322
Active Member
#3 | Posted: 5 Jan 2015 04:01 
Thanks and yes, the idea is probably correct. The point is to compare the message IDs and if there's at least one found the result is TRUE.. I hope Paul will find some trick to do it ;).

Author Paul
Lead Developer 
#4 | Posted: 5 Jan 2015 12:26 
Before the topic loads, there could be an extra request in bb_plugins.php which asks DB if such user ID is in the messages related to this topic. For example (I did not test it):

$userPosted=FALSE;
$userPostedTxt='';
if($user_id>0 and $row=db_simpleSelect(0, $Tp, 'count(*)', 'poster_id', '=', $user_id, '', '', 'topic_id', '=', $topic) and $row[0]>0) $userPosted=TRUE;
if($userPosted) $userPostedTxt='I have posted in this topic';
Then {$userPostedTxt} is for header template or other template.

Author tom322
Active Member
#5 | Posted: 8 Jan 2015 04:46 
It works perfectly. Thank you!

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Condition to check if currently logged user posted in a topic
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


 ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Proceed with the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑