@donaldsoncd Try adding this bit to the JS tab. It’ll only hide the buttons on your user pages. The buttons still show on the user card.
import { apiInitializer } from "discourse/lib/api";
export default apiInitializer((api) => {
api.onPageChange((url, title) => {
if (url.startsWith("/u/natedhaliwal")) {
const pmBtn = document.querySelector("button.compose-pm");
pmBtn.style.display = "none";
const chatBtn = document.querySelector("li.user-card-below-message-button.chat-button");
if (chatBtn.parentNode.className != "usercard-controls") {
chatBtn.style.display = "none";
}
}
});
});
It’s a bit hacky but gets the job done.
You can replace the part /u/natedhaliwal
with /u/<username>
.
If you want to completely remove the ability for anyone to PM or chat with you, you’ll need to:
- Go to
discourse.example.com/my/preferences/users
. - Uncheck the checkbox
Allow other users to send me personal messages and chat direct messages
.
Hope all that helps!