Add a "Private Message" button on Post

Do you think it is possible to add a “Private Message” button to the topic first post? :thinking:

I am surprised that many users don’t know how to send PM to OP, because the PM button is not visible unless they click on the OP’s avatar.

For example,

Currently, I am using the " discourse-custom-topic-button" plugin.

And use the url of<TOPIC_USERNAME>&title=Re:<TOPIC_TITLE>

However, when user click on the button, it jump to the front page immediately, before the Message editor show up. It doesn’t act the same as the “Message” button in user card. If you click on the “Message” button in user card, it show up the message editor immediate without jumping to other page.

Do you think it is possible to make the custom button (new-message url) act the same as the Message button in user card ? :thinking:

I recently built this for a client:

It is open-source. It may suit your needs. Just add the Categories you want it to appear in. Let me know if you hit any bugs.

Unfortunately I don’t have time to extend it at present.

Thanks to @davidkingham for commissioning us to do the work and allowing this to be open source, and in turn therefore supporting the wider community.


Thank you very much. :smiling_face_with_three_hearts: :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:

It works exactly what I am looking for. :partying_face: :partying_face: :partying_face:

Just out of curiosity, :grinning:

Do you think I can add
{{#if this.user.can_send_private_message_to_user}}
to “pm-topic-author.hbs” , so that the button won’t show up if the user is the same as the OP ? :thinking:

Similar to Discourse User card “user-card-contents.hbs



Good catch!

Given we already have the showPMTopicAuthorButton property, we should probably do that in JS, though your solution is a great interim approach.


So I’ve done that with JS:

Thanks for your feedback.

Upgrade when you get chance and please confirm that works for you.


Thank you very much for the update. :smiling_face_with_three_hearts: :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:

Now It works perfectly well for login user. :partying_face: :partying_face: :partying_face:

However, it seem after updated, the plugin cause some error for non-login user. When non-login user visit the page, it get a blank post. It only show the title, category, tag, but everything below is empty . :thinking:

Browser Inspector:

Error log:

1 Like
Schoolboy error :man_facepalming:t3:- introduced that in last change. Hopefully that resolves it for you :slight_smile: