Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Alanar on August 22, 2015, 08:55:41 PM

Title: Check if a user has posted in a specific board
Post by: Alanar on August 22, 2015, 08:55:41 PM
As the title says, I was wondering if there was a way to see if a user has posted in a specific board and use that information outside the forum such as with SSI.php or some other method.
Title: Re: Check if a user has posted in a specific board
Post by: Pipke on August 26, 2015, 07:49:15 AM
The user you mean must that be the user who is logged in atm or a specific numbered member id. Just a note if you have a large forum the query wich must be done at the db will be huge.
Title: Re: Check if a user has posted in a specific board
Post by: Kindred on August 26, 2015, 08:35:27 AM
even without a large forum...   with more than a few users, a few board and a few posts -- we are talking about at a query on two of the largest tables with at least 2 joins...

in other words...  this query would QUICKLY bog down anything other than a dedicated server... and even then it will bog down if you forum is even the least bit active.
Title: Re: Check if a user has posted in a specific board
Post by: margarett on August 26, 2015, 12:05:49 PM
No, you're wrong, sorry... It's just a simple "COUNT" in smf_messages...
That table contains both id_board and id_member so it's just a simple select operation, with a WHERE in 2 fields that are even a key (show_posts). It can't get much better ;)
Title: Re: Check if a user has posted in a specific board
Post by: Kindred on August 26, 2015, 12:17:45 PM
ummm...  well, I am frequently wrong when it comes to database crap. :)

hmmm....  yup... member and board arelisted for each entry  I guess it is not nearly as intensive as I thought. :D


SELECT COUNT(*) FROM `smf_messages` WHERE `id_board`=1 AND `id_member`=1

works...


so. run the check and then consider it a YES if the COUNT returned is greater than 0
Title: Re: Check if a user has posted in a specific board
Post by: Pipke on August 26, 2015, 12:44:28 PM
Quote from: margarett on August 26, 2015, 12:05:49 PM
No, you're wrong, sorry... It's just a simple "COUNT" in smf_messages...
That table contains both id_board and id_member so it's just a simple select operation, with a WHERE in 2 fields that are even a key (show_posts). It can't get much better ;)

If it must be the user wich is logged in and youre having 40 members logged in , then that query runs 40 times, yeah that will be heavy db query on that board wich has maybe 2000+ or more messages, or do i think wrong here?
Title: Re: Check if a user has posted in a specific board
Post by: Kindred on August 26, 2015, 12:47:24 PM
Pipke,

It certain does NOT need to be the user that is logged in.

I ran that query directly in mySQL and I was not even logged in at all.

you just have to provide A NUMBER for the WHERE `id_member`=... statement.... You can get that number any way you want -- by asking for it in a form, by using an array, or by cycling through each and every user...
Title: Re: Check if a user has posted in a specific board
Post by: Alanar on September 09, 2015, 07:07:19 PM
Haha. I've been busy so hadn't viewed the replies here. Yes, it would be the member currently logged in and viewing the page. Thanks for all the responses!
Title: Re: Check if a user has posted in a specific board
Post by: Pipke on September 10, 2015, 07:37:51 AM
This is marked as solved? As i see it in the above reply it doesnt?
Title: Re: Check if a user has posted in a specific board
Post by: Alanar on September 11, 2015, 10:37:05 AM
I'm just using it to show a user whether or not they have posted in a board as part of our application process. It only needs to be the one user who is viewing the page. I have a few options for verifying that they've submitted an application  thread so this is just one possibility.