miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | 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
Registered
#1 | Posted: 5 Jan 2015 00:59 | Edited by: tom322 
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
Registered
#2 | Posted: 5 Jan 2015 01:24 | Edited by: kuopassa 
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
Registered
#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 | Edited by: Paul 
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
Registered
#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 Top

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

 Short link for this topic:

 ?
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB