MyBB Community Forums

Full Version: Hook to act on change in post count of user
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi there I'd like to change a field depending on a users post count.

Hence I'm trying to hook into functions whenever the post count would change. I'm looking at editpost_deletepost currently but it seems that the hook is in the beginning of 'code section' (editpost.php) hence the post count would be 1 more when the hook is called if I'm correct?

Can I just move $plugins->run_hooks("editpost_deletepost"); to the end of the code section? Is there any 'clean' way to handle this directly within my plugin installation?

Thank you. Smile
Try showthread hooks.
that is a lot of hooks to try to use, if there are any that work were ever you are working with.

consider editpost, newpost, inline moderation to delete a post, inline mod to delete a thread, inline mod to move a thread to a forum where post counts do/dont matter, ACP changes to remove a forum, etc.

if you dont require immediate changes based on postcount, create a task that runs ever 30 minutes to make the changes you need.
It would be preferable to be in real time.

The showthread hook seems like a pretty genius idea. Thank you. Smile
(2012-07-26, 07:42 PM)chrisssy Wrote: [ -> ]It would be preferable to be in real time.

The showthread hook seems like a pretty genius idea. Thank you. Smile

How come? No DB changes are made regarding the post count in the showthread page except for he quick reply AFIAK >_>
(2012-07-26, 07:42 PM)chrisssy Wrote: [ -> ]It would be preferable to be in real time.

The showthread hook seems like a pretty genius idea. Thank you. Smile
Preferable is not required.
(2012-07-26, 07:47 PM)Omar G. Wrote: [ -> ]
(2012-07-26, 07:42 PM)chrisssy Wrote: [ -> ]It would be preferable to be in real time.

The showthread hook seems like a pretty genius idea. Thank you. Smile

How come? No DB changes are made regarding the post count in the showthread page except for he quick reply AFIAK >_>

Exactly, showthread has nothing to do with post count of a user. And even if it was quick reply but that is in xmlhttp.PHP and not showerhead.
Quick reply is actually in newreply.php, but regardless showthread is still irrelevant to the postcount. The best way would be a task but if that's not possible I would focus on the insert post hooks in inc/datahandlers/post.php and the delete post hook in inc/class_moderation.php.
You can also think about using the postbit hook if you don't want to deal with the many that pavemen mentioned some posts behind.

But if you don't do it right you will end with a resources hog.
Indeed you have a point Omar, I failed to mention one thing. Depending on the post_count of a user I'd like to determine weather his allowed to view a certain forum category or not.

Hence if the 'post_count' value is calculated every time before the show thread is 'run' then it'll be able to determine weather the user is applicable or not. Hence why real time would be preferred.

I've actually just realised I mistook showthread for viewing the list of 'threads' in any particular forum category... Ughhhh... I'll have another look through the documentation. Sorry if I befuddled anyone.
then just use group promotions and user group permissions to do all that. its all ready built in. create a custom group, set its permissions for the forum. then create a group promotion based on post count and assign that new group as an additional group.

then when the promotion task runs, the user will get access.
Pages: 1 2