Add-on Paid Job: Update specific table when a user makes a post / reply

NDM

Member
Hello,

I am in need of a pretty simply add-on which basically updates a table when a user makes a post or posts a reply.

My table structure is:
table name: xf_credits
cid (INT 11 AI)
user_id (INT 11)
points (INT 11)
reason (varchar 150)

Now what I need is this: I need a add-on which basically does two things:

If a user creates a topic, two points are added to the points field - in mysql terms:
update xf_credits set points=points+2 where user_id = '$uid'

If a user replies to a topic, we add one credit as in:
update xf_credits set points=points+1 where user_id = '$uid'

I am sure it's not really called $uid in XF, but I am sure you know the values anyways.

I do NOT need a admin interface or anything. Just a simply hack. The user_id field will have the same valus as the xf_users user_id to keep things simple :)

Let me know how fast you could do something like this (I really needed this one since yesterday) and how much you would charge.

Thank you very much :)
 
It looks like this might be possible by extending XenForo_ControllerPublic_Thread::actionAddReply() and performing your query after the writer save.

As for new thread, the same again, but using XenForo_ControllerPublic_Forum::actionAddThread()
 
@James If I just knew where to add the "plug" I would be happy lol. I am good with php, but XF has so many files that it would take hours for me to find out where to add my query. If you have an idea, just name the price and tell me where I would add that query :)

Thanks
 
I'm not 100% sure I haven't dug deep, just hazarding a guess there.

I'll have a look deeper in a little while, see if I can do anything.
 
It looks like this might be possible by extending XenForo_ControllerPublic_Thread::actionAddReply() and performing your query after the writer save.

As for new thread, the same again, but using XenForo_ControllerPublic_Forum::actionAddThread()
Best thing to extend after the datawriter has saved is the _postSave function.

So XenForo_DataWriter_Thread::_postSave()
 
Mr. Goodie2Shoes accepted the job. Will update this once completed and everything works fine.
Thanks again for all your help and James, if you were looking hard for me, let me know and I'll send you a donation for having a look at it for me :)

It's nearly Christmas after all.
 
Just came back to re-suggest extending the DW hahaha, Chris beat me to it.

Glad to see you resolved this :)
 
True...

You can extend XenForo_DataWriter_DiscussionMessage_Post::_messagePostSave and some other DataWriter classes though.
 
Top Bottom