Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Forcing Discussions to be Whispered
I would like to know if it is possible to force all discussions created by a user to be whispered to themselves. Would it be as simple as:
a) Using JavaScript to fill the whisper field with the users name
b) Having the users name pre-filled in the whisper-to field.
Or would there be a better way with an extension of some sort.
I am not sure how to go about this, so if anyone could lend a hand, it would be greatly appreciated.
--
Nathan.
0
This discussion has been closed.
Comments
I would suggest creating a new theme with the file. Change this block:
if ($this->Context->Configuration['ENABLE_WHISPERS'] && $Discussion->DiscussionID == 0) { echo '<li> <label for="WhisperUsername">'.$this->Context->GetDefinition('WhisperYourCommentsTo').'</label> <input id="WhisperUsername" name="WhisperUsername" type="text" value="'.FormatStringForDisplay($Discussion->WhisperUsername, 0).'" class="Whisper AutoCompleteInput" maxlength="20" /> <script type="text/javascript"> var WhisperAutoComplete = new AutoComplete("WhisperUsername", false); WhisperAutoComplete.TableID = "WhisperAutoCompleteResults"; WhisperAutoComplete.KeywordSourceUrl = "'.$this->Context->Configuration['WEB_ROOT'].'ajax/getusers.php?Search="; </script> </li> '; }
To:<input id="WhisperUsername" name="WhisperUsername" type="hidden" value="'. $this->Context->Session->UserID .'" />
And that should work for you. You might still ned that IF statement, but I suspect it is OK to replace it completely. Test editing the messages to make sure.I did the new theme thing (I had a new one already), and I used the following code (you still need to echo the code, you can't just replace it entirely).
if ($this->Context->Configuration['ENABLE_WHISPERS'] && $Discussion->DiscussionID == 0) { echo '<input id="WhisperUsername" name="WhisperUsername" type="hidden" value="'. $this->Context->Session->UserID .'" /> '; }
I get this error when I try and make a post:
The username entered as the whisper recipient could not be found.
I assume that UserID will return a number, i.e. 1, or 43 which is not a valid User Name. Is there a way to insert a UserName?
Thanks though. Very nearly there.
Unless there is an extension that does this... that is.
$this->User->Name
I can't use that. It doesn't work.
Maybe I will be able to poke through the code more later today and find it.
if (!@$UserManager) $UserManager = $Context->ObjectFactory->NewContextObject($Context, "UserManager");
$AccountUserID = ForceIncomingInt("u", $Context->Session->UserID);
$AccountUser = $UserManager->GetUserById($AccountUserID);
$name = $AccountUser->Name;
so replace $context by $this->Context:
$this->Context->Session->User->Name