XF 2.2 Only allowing a single reply per thread type. (quick reply)


Well-known member
I have a thread type where I only want users to reply once. The part that is not working is after a quick reply. Any method to completely hide the quick reply functionality once a reply is made?
You want to set this contraint per thread or per forum?
Per thread. I can modify the canReply function to check for a thread type and see how many replies a user has to show or hide the quick reply box. However, if the user is able to reply using the quick reply box, I need to hide it right after the quick reply happens. I am sure I can monitor a quick reply event and maybe hide it that way...
Just to update this thread with my solution, I was able to remove the AJAX ability to slide in the new reply to the end of the thread and simply have the page reload after submitting a new post. Once the page is reloaded, the reply box is now gone.
Any chance you can share the solution so that in future if someone has a similar use case, he/she refer to this thread.
Pretty simple actually. I created a new template for rendering threads of a specific forum type and update the for tag to take a variable(true or false) for the ajax flag. I have multiple thread types and only 1 of those types is limited to only 1 reply:

<xf:form action="{{ link('threads/add-reply', $thread) }}"
    draft="{{ link('threads/draft', $thread) }}"
    class="block js-quickReply"
    data-xf-init="attachment-manager quick-reply{{ ($xf.visitor.isShownCaptcha() AND !$isPreRegReply) ? ' guest-captcha' : '' }}"
    data-message-container="div[data-type='post'] .js-replyNewMessageContainer">

All lines are exactly the same except the 2 line which is the ajax attribute.
Top Bottom