XF 2.3 “Send Message” button under the username in thread posts

indicator

Member
Licensed customer
I want to add “Send Message” button under the username in thread posts so that button can take to the send private message area.
 
FYI

i used gemini and worked fine. here are the code if anyone find it useful

Go to message_macros template
After the line
Code:
<xf:userbanners user="$user" tag="div" class="message-userBanner" itemprop="{{ $includeMicrodata ? 'jobTitle' : '' }}" />
Paste the following
Code:
<xf:if is="$user.user_id AND $user.user_id != $xf.visitor.user_id AND $xf.visitor.canStartConversationWith($user)">
    <div class="message-userExtras">
        <a href="{{ link('conversations/add', null, {'to': $user.username}) }}"
           class="button button--small button--link button--fullWidth"
           data-xf-click="overlay">
            Message
        </a>
    </div>
</xf:if>
 
You can do this with a template modification on message_macros. Add this right after the user banners section:
Code:
<xf:if is="$user.user_id AND $user.user_id != $xf.visitor.user_id AND $xf.visitor.canStartConversationWith($user)">
    <div class="message-userExtras">
        <a href="{{ link('conversations/add', null, {'to': $user.username}) }}"
           class="button button--small button--link"
           data-xf-click="overlay">
            Send Message
        </a>
    </div>
</xf:if>
This checks that the viewer isn't looking at their own post and has permission to message that user. The data-xf-click="overlay" makes it open as a modal instead of navigating away. The canStartConversationWith() check respects the target user's privacy settings and block list.
To set it up as a template modification: go to ACP > Appearance > Template modifications, create one on message_macros, find the closing tag after the user banners block, and insert the code above after it.
 
Back
Top Bottom