1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Resource and Add-on Requests' started by NDM, Dec 24, 2012.

  1. NDM

    NDM Member


    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 :)
  2. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Can you please PM me with your budget?

  3. James

    James Well-Known Member

    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()
  4. NDM

    NDM Member

    @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 :)

  5. James

    James Well-Known Member

    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.
  6. NDM

    NDM Member

    Thanks so much for looking :) The support in this community is simply great :)
  7. Chris D

    Chris D XenForo Developer Staff Member

    Best thing to extend after the datawriter has saved is the _postSave function.

    So XenForo_DataWriter_Thread::_postSave()
    James likes this.
  8. NDM

    NDM Member

    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.
  9. James

    James Well-Known Member

    Just came back to re-suggest extending the DW hahaha, Chris beat me to it.

    Glad to see you resolved this :)
  10. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    You can't extend the _postSave() function for the DiscussionMessage classes as they are marked as 'final' ;)
  11. Chris D

    Chris D XenForo Developer Staff Member


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

Share This Page