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.

Contact Form

edited March 2007 in Vanilla 1.0 Help
Contact Form

Comments

  • Jazzman, how does this work? Does it create a link somewhere to a contact form, or do you have to do it manually?
  • It adds a tab. But you can also create a link anywhere on your forum: http://www.myforum.com/vanilla/extension.php?PostBackAction=ContactForm
  • Excellent, I saw the need for this and hard-coded a contact form using Page Manager.
    This extension is great, what do you mean by "The upload directory should be writeable (chmod 777)" in the read-me?
    Are you planning to allow attachments?

    Posted: Friday, 16 March 2007 at 8:09AM (AEDT)

  • Great stuf...

    Speaking of ContactForm & PageManager: If you install this add-on and do not see the contact tab, be sure to Re-Sync the PageManager tabs.

    Small note to Jazz, in admin change
    ...who will receive the emails which are send by the contact form. to
    ...who will receive the emails which are sent by the contact form.
  • @Wanderer... LOL.. have to remove that :P I copied the readme from my attachments addon.. @TomTester: thanks, I will change it in the next release ;)
  • This extension is great. Thanks Jazzman.

    I tweaked the code a bit so that users who are signed in don't have to enter their name or email address. It seems to work fine, but I'm not sure if I've missed anything.

    Take a look and add it into the next release if you think it'll work:

    function ContactForm(&$Context) { $this->Name = 'ContactForm'; $this->ValidActions = array('ContactForm', 'ProcessContactForm'); $this->Constructor($Context); $this->ContactName = $this->Context->Configuration['CONTACTFORM_CONTACT_NAME']; $this->ContactEmail = $this->Context->Configuration['CONTACTFORM_CONTACT_EMAIL']; if ($this->IsPostBack) { $this->Context->PageTitle = $Context->GetDefinition('ContactForm'); $this->Email = $this->Context->ObjectFactory->NewContextObject($this->Context, 'Email'); if ($this->Context->Session->UserID == 0) { $this->Email->FromName = ForceIncomingString('FromName', ''); $this->Email->FromEmail = ForceIncomingString('FromEmail', ''); } if ($this->Context->Session->UserID > 0) { $UserManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'UserManager'); $User = $UserManager->GetUserById($this->Context->Session->UserID); $this->Email->FromName = $User->Name; $this->Email->FromEmail = $User->Email; } $this->Email->Subject = ForceIncomingString('Subject', ''); $this->Email->Body = ForceIncomingString('Body', ''); $this->Email->AddRecipient($this->ContactEmail, $this->ContactName); if ($this->PostBackAction == 'ProcessContactForm') { $this->Email->Send(); if ($this->Context->WarningCollector->Count() == 0) header("Location: " . GetUrl($this->Context->Configuration, 'extension.php', '', '', '', '', 'PostBackAction=ContactForm&Success=1')); } } $this->CallDelegate('Constructor'); } function Render() { if ($this->IsPostBack) { $this->CallDelegate('PreRender'); $this->PostBackParams->Set('PostBackAction', 'ProcessContactForm'); $Required = $this->Context->GetDefinition('Required'); echo ' <div id="Form" class="Account ContactForm"> <fieldset> <legend>'.$this->Context->GetDefinition('ContactForm').'</legend> '.(ForceIncomingBool('Success', 0) ? '<div id="Success">'.$this->Context->GetDefinition('MessageSent').'</div>' : '').' '.$this->Get_Warnings().' '.$this->Get_PostBackForm('frmContactForm').' <p class="Description">'.str_replace("//1", $this->ContactName, $this->Context->GetDefinition('ContactFormNotes')).'</p> <ul>'; if ($this->Context->Session->UserID == 0) { echo'<li> <label for="txtFromName">'.$this->Context->GetDefinition('YourName').' <small>'.$Required.'</small></label> <input type="text" name="FromName" id="txtFromName" value="'.$this->Email->FromName.'" class="SmallInput" /> </li> <li> <label for="txtFromEmail">'.$this->Context->GetDefinition('YourEmail').' <small>'.$Required.'</small></label> <input type="text" name="FromEmail" id="txtFromEmail" value="'.$this->Email->FromEmail.'" class="SmallInput" /> </li>'; } echo'<li> <label for="txtSubject">'.$this->Context->GetDefinition('Subject').' <small>'.$Required.'</small></label> <input type="text" name="Subject" id="txtSubject" value="'.$this->Email->Subject.'" class="SmallInput" /> </li> <li> <label for="txtBody">'.$this->Context->GetDefinition('Message').' <small>'.$Required.'</small></label> <textarea name="Body" id="txtBody">'.$this->Email->Body.'</textarea> </li> </ul> <div class="Submit"> <input type="submit" name="btnSave" value="'.$this->Context->GetDefinition('SendMessage').'" class="Button SubmitButton StartDiscussionButton" onclick="'."Wait(this, '".$this->Context->GetDefinition('Wait')."');".'"/> <a href="'.(!$this->IsPostBack?'javascript:history.back();':'./').'" class="CancelButton">'.$this->Context->GetDefinition('Cancel').'</a> </div> </form> </fieldset> </div>'; $this->CallDelegate('PostRender'); } }
  • What do we put into the .htaccess to make this friendly URL?
  • I've done that. I have friendly URLs working, but they don't cover the Contact form.. just like with the Page Manager how you have to add another line into the .htaccess, i'm wondering what I add to get the Contact Form URL made friendly.
  • I've done it on my website the old fashion way :-)

    Just add this:

    RewriteRule ^([^/]*)\.html$ /extension.php?PostBackAction=$1 [L]
    to your .htaccess
  • I like that sjeeps (without the .html :D).
  • @[-Stash-] "I like that sjeeps (without the .html :D)."
    Well, it's friendly enough! :D
  • Does anyone know how I can edit the format that the email is sent in? I would like a fixed subject line before what the user types so I know where the email came from in my inbox. (I forward my support emails to my main account so I don't have to check two different accounts) Any help would be appreciated, thanks.
  • a suggestion, and a question; 1. this form badly needs verification. i had to disable it on my site because of the amount of spam i was getting. 2. does anything like this exist for emailing individual users? seeing as the private messages extension has a seemingly massive security flaw, i need something basic to replace it.
  • Works Great for me, however is there a way we can restrict it to the registered users only?
This discussion has been closed.