Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<img src="pix/logo.png" align="right" />
2
 
3
Local Contact Form plugin for Moodle
4
====================================
5
![PHP](https://img.shields.io/badge/PHP-v5.6%20to%20v8.3-blue.svg)
6
![Moodle](https://img.shields.io/badge/Moodle-v3.0%20to%20v4.4-orange.svg)
7
[![GitHub Issues](https://img.shields.io/github/issues/michael-milette/moodle-local_contact.svg)](https://github.com/michael-milette/moodle-local_contact/issues)
8
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-green.svg)](#contributing)
9
[![License](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](#license)
10
 
11
# Table of Contents
12
 
13
- [Basic Overview](#basic-overview)
14
- [Requirements](#requirements)
15
- [Download Contact for Moodle](#download-contact-for-moodle)
16
- [Installation](#installation)
17
- [Usage](#usage)
18
- [Updating](#updating)
19
- [Uninstallation](#uninstallation)
20
- [Limitations](#limitations)
21
- [Language Support](#language-support)
22
- [Frequently Asked Questions (FAQ)](#faq)
23
- [Contributing](#contributing)
24
- [Motivation for this plugin](#motivation-for-this-plugin)
25
- [Further information](#further-information)
26
- [License](#license)
27
 
28
# Basic Overview
29
 
30
The Contact Form plugin for Moodle processes information submitted through a web form, sending it by email.
31
 
32
Examples uses for this plugin include:
33
 
34
* Contact us form;
35
* Support request form;
36
* Request a course form;
37
* Information request form;
38
* Lead generation form;
39
* Membership application form.
40
* Quiz question issue report form.
41
 
42
Several pre-configured templates are available when used with the [FilterCodes](https://moodle.org/plugins/filter_filtercodes/) plugin. They include:
43
* {formquickquestion}
44
* {formcontactus}
45
* {formcourserequest}
46
* {formsupport}
47
* {formcheckin}
48
 
49
See [The Quick and Easy method](#the-quick-and-easy-method) for details.
50
 
51
[(Back to top)](#table-of-contents)
52
 
53
# Requirements
54
 
55
This plugin requires Moodle 3.0+ from https://moodle.org .
56
 
57
It may work with previous versions of Moodle all the way back to Moodle 2.7 but it has not been tested yet. If it works for you, let us know. Tip: You might need to modify the version.php in order for Moodle to let you install it on earlier versions.
58
 
59
[(Back to top)](#table-of-contents)
60
 
61
# Download Contact for Moodle
62
 
63
The most recent STABLE release of Contact Form for Moodle is available from:
64
https://moodle.org/plugins/local_contact
65
 
66
The most recent DEVELOPMENT release can be found at:
67
https://github.com/michael-milette/moodle-local_contact
68
 
69
[(Back to top)](#table-of-contents)
70
 
71
# Installation
72
 
73
Install the plugin, like any other plugin, to the following folder:
74
 
75
    /local/contact
76
 
77
See https://docs.moodle.org/en/Installing_plugins for details on installing Moodle plugins.
78
 
79
[(Back to top)](#table-of-contents)
80
 
81
# Usage
82
 
83
Before getting started:
84
 
85
* Ensure email settings are properly configured in Moodle.
86
* Ensure that you have configured the support name and email address in Moodle.
87
 
88
## Creating a new form
89
 
90
### The Quick and Easy method
91
 
92
By far, The quickest way to get started is to use the [FilterCodes](https://moodle.org/plugins/filter_filtercodes/) Moodle plugin. As of version 1.3.0, it includes several plain text tags that you can easily copy and paste into any Atto editor. The {tags} include:
93
 
94
* {formquickquestion} : Adds a "quick question" form to your course. Form only includes a Subject and Message field. Note: User must be logged in or the form will not be displayed.
95
* {formcontactus} : Adds a "Contact Us" form to your site (example: in a page). Form includes Name, Email address, Subject and Message fields.
96
* {formcourserequest} : Adds a "Course Request" form to your site (example: in a page). Unlike Moodle's request-a-course feature where you can request to create your own course, this tag allows users to request that a course they are interested in be created. Could also be used to request to take a course. Form includes Name, Email address, Course name, Course Description.
97
* {formsupport} : Adds a "Support Request" form to your site (example: in a page). Form includes Name, Email address, pre-determined Subject, specific Subject, URL and Message fields.
98
* {formcheckin} : Adds a "I'm here!" button to your to your course. Form does not include any other fields. Note: User must be logged in or the button will not be displayed.
99
 
100
### Custom method
101
 
102
This plugin is for administrators with a little knowledge of HTML forms. You can simply copy and paste any of the [examples from the Wiki](https://github.com/michael-milette/moodle-local_contact/wiki/HTML-Form-Templates) to get started.
103
 
104
To create a new web form on your site, start by adding a Moodle page or HTML block. Be sure to switch to the Source Code view button in the Moodle Atto WYSIWYG editor before entering or pasting HTML code similar to the following:
105
 
106
    <form action="../../local/contact/index.php" method="post" class="contact-us">
107
        <fieldset>
108
            <label for="name" id="namelabel">Your name <strong class="required">(required)</strong></label><br>
109
            <input id="name" name="name" type="text" size="57" maxlength="45" pattern="[A-zÀ-ž]([A-zÀ-ž\s]){2,}"
110
                    title="Minimum 3 letters/spaces." required="required" value=""><br>
111
            <label for="email" id="emaillabel">Email address <strong class="required">(required)</strong></label><br>
112
            <input id="email" name="email" type="email" size="57" maxlength="60" required="required" value=""><br>
113
            <label for="subject" id="subjectlabel">Subject <strong class="required">(required)</strong></label><br>
114
            <input id="subject" name="subject" type="text" size="57" maxlength="80" minlength="5"
115
                    title="Minimum 5 characters." required="required"><br>
116
            <label for="message" id="messagelabel">Message <strong class="required">(required)</strong></label><br>
117
            <textarea id="message" name="message" rows="5" cols="58" minlength="5"
118
                    title="Minimum 5 characters." required="required"></textarea><br>
119
            <input type="hidden" id="sesskey" name="sesskey" value="">
120
            <script>document.getElementById('sesskey').value = M.cfg.sesskey;</script>
121
        </fieldset>
122
        <div>
123
            <input type="submit" name="submit" id="submit" value="Send">
124
        </div>
125
    </form>
126
 
127
That is it. Just save and you are done.
128
 
129
Note: If you are putting the form into a block, you will need to adjust the "../.." part in the action of the form so that it is relative to the webroot of your Moodle website. If you are using the FilterCodes plugin, you can simply use {wwwroot} and it will work anywhere you put the form whether it is in a page or a block.
130
 
131
Example:
132
 
133
    <form action="{wwwroot}/local/contact/index.php" method="post" class="contact-us">
134
    :       :       :       :       :
135
 
136
To see a full example of the above form, see [Contact Us with FilterCodes example](https://github.com/michael-milette/moodle-local_contact/wiki/HTML-Form-Templates#user-content-contact-us-form-with-filtercodes-for-contact-form-for-moodle).
137
 
138
### Customizing the form
139
 
140
You can customize your form to suit your particular requirements. You will need to be familiar with how to create basic HTML5 web forms. If you are not, take a look at the [HTML5 Forms tutorial](https://www.html5-tutorials.org/forms/introduction/).
141
 
142
Almost any type of HTML field included with the form should automatically appear in the email. Example: text, password, textarea, radio, checkbox, select drop-down, hidden and more. See the section on [Limitations](#limitations).
143
 
144
In the previous example, the form's class "contact-us" is not required but is simply included to help you to apply CSS styling to the form. Feel free to change it to anything you like.
145
 
146
**REQUIRED FIELDS:** The following input fields are required in order to avoid the built-in anti-spam protection. If these input fields are not present in the form, it will not work:
147
 
148
1. **name** - You can create an alias for this field name by editing the **field-name** string in the Moodle language editor. If user is logged in, this field will be ignored and the users full name as registered in Moodle will be used instead. If the user is currently logged in (not guest), this field will be ignored if it exists and user profile info (firstname lastname) will be used instead.
149
2. **email** - You can create an alias for this field name by editing the **field-email** string in the Moodle language editor. If the user is currently logged in (not guest), this field will be ignored if it exists and user profile info (firstname lastname) will be used instead.
150
3. **sesskey** - Must include both the hidden **sesskey** field as well as the SCRIPT line below it.
151
4. **submit** - The name of the button.
152
 
153
Your FORM tag must have an action set to **../../local/contact/index.php** and a method set to **post**.
154
 
155
**OPTIONAL FIELDS:** Although not required, the following fields have special meaning to Contact Form:
156
 
157
* **subject**  : If you want the subject of the email to contain content from the submitted web form, your form must include a field called **subject**. You can create an alias for this field name by editing the **field-subject** string in the Moodle language editor.
158
* **message**  : If you want a textarea field, like a Message field, to be formatted properly when inserted in the email, the field must be called **message**. You can create an alias for this field name by editing the **field-message** string in the Moodle language editor.
159
* **recipient**: Add this field if you want to specify a recipient other than the Moodle support email address. This field must contain an alias, not an email address. See the section on Configuring the List of Recipients in this documentation.
160
 
161
You can also add the referring URL, the page that the user was on before going to the form, by adding the following to your form:
162
 
163
    <input type="hidden" id="referrer" name="referrer" value="">
164
    <script>document.getElementById('referrer').value = document.referrer;</script>
165
 
166
An side benefit to including these two lines is that the **Continue** button, which appears after you submit the form, will take the user back to the form's referrer URL instead the site's front page.
167
 
168
If you would rather have the **Continue** button take the user back to the form itself, simply replace **document.referrer** with **document.location.href**. So the above two lines would become:
169
 
170
    <input type="hidden" id="referrer" name="referrer" value="">
171
    <script>document.getElementById('referrer').value = document.location.href;</script>
172
 
173
This will result in the form's address being inserted into the email in the referrer field
174
 
175
If you prefer to have the continue button always take the user to a different page, you can specify the URL in the input field. Just be sure that the page is on the Moodle site. The continue button will not allow you to take the user to a different website. Example:
176
 
177
    <input type="hidden" id="referrer" name="referrer" value="https://moodle.example.com/mod/page/view.php?id=21">
178
 
179
Note that, in these two last examples, the referrer field will no longer actually refer to the page from where the user actually came from before the form which can be a little misleading. For a support page, it is recommended to use **document.referrer** with the script tag in order to submit the URL of the page from where they came. This will be helpful when the student submits something like "Lesson 2 of the course didn't work" but offers no clue which course they were in at the time.
180
 
181
Returning the student back to the page they were on before the form was submitted is also helpful if it would be rather complicated to navigate back to where they were before they submitted the form. This is especially important if you are dealing with students who may have accessibility issues.
182
 
183
#### Additional tips
184
 
185
If you want to insert spaces in your field names, use underscores "_" in your form field id and name. Contact Form for Moodle will replace these with a space before inserting the field name into the email message.
186
 
187
Field id/name tokens must begin with a letter. They may optionally also contain any combination of letters (a-z), numbers (0-9), underscores, dashes, periods and colons (_-.:). They are not case sensitive.
188
 
189
## Configuring the email message
190
 
191
To edit the language strings including the email message to be sent to the user, you will need to make the changes using the Moodle language editor. To do this:
192
 
193
1. Login to Moodle as an Administrator
194
2. Navigate to **Home** > **Site Administration** > **Language** > **Language Customization**.
195
3. Select the language you wish to modify and then click **Open Language Pack for Editing** button.
196
4. Select the local_contact.php from the list and click the **Show Strings** button.
197
 
198
For more information on using the language editor, see the [Moodle documentation on Language Customization](https://docs.moodle.org/en/Language_customisation#Using_the_obtained_information_in_order_to_change_the_intended_strings).
199
 
200
The message can include the following tags which will be substituted at the time the message is sent:
201
 
202
* **[fromemail]**      : User's email address as entered in the web form or the users registered email address if logged in.
203
* **[fromname]**       : User's name as entered in the web form or the users registered first and last name if logged in.
204
* **[http_referer]**   : URL of the web form page that the email was generated from.
205
* **[http_user_agent]**: Web browser.
206
* **[lang]**           : Language that the user was viewing the website in at the time they submitted the form.
207
* **[sitefullname]**   : Site's fullname.
208
* **[siteshortname]**  : Site's short name.
209
* **[siteurl]**        : URL of the website.
210
* **[supportemail]**   : Site's support email address.
211
* **[supportname]**    : Site's support name.
212
* **[userip]**         : Best attempt to determine the user's IP address. Will be the firewall address if they are behind one.
213
* **[userstatus]**     : Displays the user's current status if they are known to the Moodle site, either because they are logged in or by their email address.
214
 
215
Note that, in the future, the email message will be configurable from within the plugin's settings.
216
 
217
## Optional Contact Form for Moodle settings
218
 
219
Contact Form for Moodle includes the following settings. These are available on the plugin's `Settings` page by going to:
220
 
221
Site administration > Plugins > Local plugins > Contact Form
222
 
223
### Override the sender's (FROM) email address
224
 
225
You can optionally specify an emails address from which emails will be sent. If this field is blank, by default emails will be delivered from the no-reply email address.
226
 
227
### Configuring the List of Recipients
228
 
229
By default, messages sent from the Contact Form for Moodle will be delivered to your Moodle support contact email address. However, you can optionally specify a different recipient on a per form basis. Configuring this requires two additional easy steps:
230
 
231
#### Step 1 - Create the List of Available Recipients
232
 
233
Start by specifying a List of Available Recipients in the plugin's settings.
234
 
235
The format for each recipient is alias|emailaddress|name. You should only enter one recipient per line. Incorrectly entered lines and blank lines will be ignored.
236
 
237
For example:
238
 
239
    tech support|support@example.com|Joe Fixit
240
    webmaster|admin@example.com|Mr. Moodle
241
    electrical|nikola.tesla@example.com|Nikola
242
    history|charles.darwin@example.com|Mr. Darwin
243
    law|issac.newton@example.com|Isaac Newton
244
    math|galileo.galilei@example.com|Galileo
245
    english|mark.twain@example.com|Mark Twain
246
    physics|albert.einstein@example.com|Albert
247
    science|thomas.edison@example.com|Mr. Edison
248
    philosophy|aristotle@example.com|Aristotle
249
 
250
Note that this list is not automatically populated in forms. You will need to do that manually in the next step.
251
 
252
#### Step 2 - Add a field to your form.
253
 
254
Single Recipient - This can be done by specifying the recipient's alias in a "hidden" type input field in your form. For example:
255
 
256
    <input type="hidden" name="recipient" id="recipient" value="webmaster">
257
 
258
One of Many Recipients - You can also create a drop-down (select) list in your form and have the user specify the recipient. For example:
259
 
260
    <select name="recipient" id="recipient" required>
261
        <option value="">Please select...</option>
262
        <option value="tech support">Technical support</option>
263
        <option value="webmaster">Moodle administrator</option>
264
    </select>
265
 
266
A different form on the same site might have:
267
 
268
    <select name="recipient" id="recipient" required>
269
        <option value="">Please select...</option>
270
        <option value="history">History teacher</option>
271
        <option value="math">Math teacher</option>
272
        <option value="english">English teacher</option>
273
        <option value="philosophy">Philosophy teacher</option>
274
    </select>
275
 
276
Notice that you can include any number of recipients in your form's drop-down list. You need not include all of them. If a specified alias is not in the List of Available Recipients, the email message will default to being delivered to the Moodle site's support email address.
277
 
278
### Select multiple items
279
 
280
If you are using a select form where you allow multiple items to be selected, all of the selected items will be merged together in a commas/space delimited list. Example:
281
 
282
    <select multiple name="cars[]" id="cars">
283
        <option value="">Please select...</option>
284
        <option value="TOYOTA">Toyota</option>
285
        <option value="GM">General Motors</option>
286
        <option value="VOLKSWAGEN">Volkswagen</option>
287
        <option value="NISSAN">Nissan</option>
288
        <option value="HYUNDAI">Hyundai</option>
289
        <option value="FORD">Ford</option>
290
        <option value="CHRYSLER">Chrysler</option>
291
        <option value="HONDA">Honda</option>
292
        <option value="BMW">BMW</option>
293
    </select>
294
 
295
Important: Don't forget to end the name of your field with [] or all you will see is the last selected item.
296
 
297
### Configuring reCAPTCHAs
298
 
299
Note: If Moodle's reCAPTCHA is not configured, you will not see this setting.
300
 
301
To use reCAPTCHA in your Contact form, you must:
302
 
303
- Configure Moodle's reCAPTCHA settings. See Site administration > Plugins > Authentication > Manage authentication. These settings are near the bottom of the page.
304
- Install and enable the [filter_filtercodes](https://moodle.org/plugins/filter_filtercodes) plugin.
305
- Add the {recaptcha} tag inside your form, usually right before the `Send` button. This will be converted into HTML code when your form is displayed. For more information on inserting a {recaptha} tag, see the [FilterCodes documentation](https://github.com/michael-milette/moodle-filter_filtercodes#usage).
306
 
307
However, even if reCAPTCHA is enabled, you can tell Contact Form for Moodle not to use it. Just go into the settings for Contact Form, check the box for `No reCAPTCHA` and save. In this case, you will not need to include the {recaptcha} tag in the form. Example:
308
 
309
    <form action="../../local/contact/index.php" method="post" class="template-form">
310
        <fieldset>
311
            <label for="name" id="namelabel">Your name <strong class="required">(required)</strong></label><br>
312
            <input id="name" name="name" type="text" pattern="[A-zÀ-ž]([A-zÀ-ž\s]){2,}" title="Minimum 3 letters/spaces." required="required" value="" style="width:100%;"><br>
313
            <label for="email" id="emaillabel">Email address <strong class="required">(required)</strong></label><br>
314
            <input id="email" name="email" type="email" required="required" value="" style="width:100%;"><br>
315
            <input type="hidden" id="sesskey" name="sesskey" value="">
316
            <script>document.getElementById('sesskey').value = M.cfg.sesskey;</script>
317
            **{recaptcha}**
318
        </fieldset>
319
        <div>
320
            <input type="submit" name="submit" id="submit" value="Send">
321
        </div>
322
    </form>
323
 
324
### Adding support for attachments
325
 
326
In order to add support for one attachment to your form, you must:
327
 
328
1. Enable attachments in the Contact Form plugin settings. Otherwise attachments will be ignored, even if you have a field for it in your form. If you try to submit an attachment but get the message `File attachments not enabled.`, you did not enable this feature.
329
2. Add `enctype="multipart/form-data"` to the <form> tag.
330
3. Add the following two tags in the form. You can change the word `Attachment a file` but everything else must remain as is.
331
 
332
```
333
<label for="attachment" id="attachmentlabel">Attachment a file</label><br>
334
<input type="file" id="attachment" name="attachment">
335
```
336
 
337
Here is a complete example of the previous Contact Us form example but with these changes:
338
 
339
   <form action="../../local/contact/index.php" method="post" class="contact-us" enctype="multipart/form-data">
340
        <fieldset>
341
            <label for="name" id="namelabel">Your name <strong class="required">(required)</strong></label><br>
342
            <input id="name" name="name" type="text" size="57" maxlength="45" pattern="[A-zÀ-ž]([A-zÀ-ž\s]){2,}"
343
                    title="Minimum 3 letters/spaces." required="required" value=""><br>
344
            <label for="email" id="emaillabel">Email address <strong class="required">(required)</strong></label><br>
345
            <input id="email" name="email" type="email" size="57" maxlength="60" required="required" value=""><br>
346
            <label for="subject" id="subjectlabel">Subject <strong class="required">(required)</strong></label><br>
347
            <input id="subject" name="subject" type="text" size="57" maxlength="80" minlength="5"
348
                    title="Minimum 5 characters." required="required"><br>
349
            <label for="message" id="messagelabel">Message <strong class="required">(required)</strong></label><br>
350
            <textarea id="message" name="message" rows="5" cols="58" minlength="5"
351
                    title="Minimum 5 characters." required="required"></textarea><br>
352
            <label for="attachment" id="attachmentlabel">Attachment a file: </label><br>
353
            <input type="file" id="attachment" name="attachment">
354
            <input type="hidden" id="sesskey" name="sesskey" value="">
355
            <script>document.getElementById('sesskey').value = M.cfg.sesskey;</script>
356
        </fieldset>
357
        <div>
358
            <input type="submit" name="submit" id="submit" value="Send">
359
        </div>
360
    </form>
361
 
362
### Require login
363
 
364
The `Require login` setting requires that users be logged-in in order to be able to submit the form. If a form is submitted and the user is not logged-in they will be redirected to the login page. If you require users to be logged-in, it is also highly recommended that you also place your form on a page which is only accessible to logged-in users. Guest users are not considered to be logged-in.
365
 
366
[(Back to top)](#table-of-contents)
367
 
368
# Updating
369
 
370
There are no special considerations required for updating the plugin.
371
 
372
The first public BETA version was released on 2016-12-05. For more information on releases since then, see
373
[CHANGELOG.md](https://github.com/michael-milette/moodle-local_contact/blob/master/CHANGELOG.md).
374
 
375
[(Back to top)](#table-of-contents)
376
 
377
# Uninstallation
378
 
379
Uninstalling the plugin by going into the following:
380
 
381
Home > Administration > Site Administration > Plugins > Manage plugins > Contact Form
382
 
383
...and click Uninstall. You may also need to manually delete the following folder:
384
 
385
    /local/contact
386
 
387
[(Back to top)](#table-of-contents)
388
 
389
# Limitations
390
 
391
This is not a form builder.
392
 
393
The plugin doesn't currently properly support more than one textarea type fields. Additional textareas will still work however they won't be formatted as nice.
394
 
395
Any HTML entered will be escaped. You cannot use any kind of HTML formatting or markup/markdown other than pressing ENTER at the end of a paragraph.
396
 
397
You cannot configure the Contact Form email processor on a per form basis. All contact forms on your site will share:
398
 
399
* The message that is displayed to the user after the message has been sent.
400
* The footer of the email containing additional user information.
401
* Enabling/disabling of the autoresponder.
402
* The autoresponder message (if enabled).
403
 
404
Web forms are limited to 1024 fields including hidden fields and the submit button. Total size of the submission may not exceed 256 KB.
405
 
406
[(Back to top)](#table-of-contents)
407
 
408
# Language Support
409
 
410
This plugin includes support for the English language. Additional languages including French are supported if you've installed one or more additional Moodle language packs.
411
 
412
Some core fields will be different if a language pack is available for your language. On a French Moodle site, for example (fielname on English site => fieldname on French site):
413
 
414
* email => courriel
415
* message => message
416
* name => nom
417
* subject => objet
418
 
419
So on a French site, you would need to use the French versions of the field names or Contact Form will not recognize them. For more information, see the section called [Customizing the form](#customizing-the-form).
420
 
421
Pro tip: Creating a multi-language Moodle site? Use the [FilterCodes](https://moodle.org/plugins/filter_filtercodes) {getstring} tag to populate the correct field name. Example:
422
 
423
Note: If no language pack is available for your language, the plugin will default to the English language pack. However, if you need a language that is not yet supported, please contribute translations using the Moodle AMOS Translation Toolkit for Moodle at:
424
 
425
https://lang.moodle.org/
426
 
427
This plugin has not been tested for right-to-left (RTL) language support. If you want to use this plugin with a RTL language and it doesn't work as-is, feel free to prepare a pull request and submit it to the project page at:
428
 
429
https://github.com/michael-milette/moodle-local_contact
430
 
431
[(Back to top)](#table-of-contents)
432
 
433
# FAQ
434
 
435
## Answers to frequently asked questions
436
 
437
### How do I make this form available to everyone, even if they are not logged in?
438
 
439
Assuming you have not enabled "Force users to log in" in Moodle settings, the easiest way is to add a page or block to your Moodle Frontpage (also known as Home page).
440
 
441
1. Login as a Moodle administrator.
442
2. Go to your Front Page.
443
3. Turn editing on.
444
4. Add a **Page** type activity/resource.
445
5. Insert your HTML form or related FilterCode (if you are using it) into the content field and save. If pasting HTML code, make sure that the WYSIWYG editor is in HTML mode.
446
 
447
Since you don't need to be logged into your Moodle Frontpage to see it, your form will also be accessible to visitors to your site who are logged-out, logged-in as a guest as well as to regular logged-in users. If this option is not available to you, the process is a little more complicated as it involves making a course available to guests and having Moodle automatically logged them in as guests.
448
 
449
### Why isn't my form working?
450
 
451
The quick and easy way to create webforms in Moodle is to simply install [FilterCodes](https://moodle.org/plugins/filter_filtercodes/) and use its tags. Be sure to set the filter to **On** in Moodle's Manage Filter settings and set it to filter **Content and headings**. Built-in forms include {formquickquestion}, {formcontactus}, {formcourserequest}, {formsupport}, {formcheckin}. [More information for FilterCodes method](#the-quick-and-easy-method).
452
 
453
 If you are not using FilterCodes, be sure to replace any reference to tags that look like {tagname} that might be found in your HTML form. [More informaiton on HTML method](#custom-method). For example, if your form contains {wwwroot} and the webroot your Moodle site is https://example.com, then replace {wwwroot}/local/contact/ with https://example.com/local/contact/ . Look through your form as there may be others depending on the sample code upon which you based your form.
454
 
455
Anytime your form doesn't work, be sure to try it in a Moodle page or block using the Boost theme with the current language set to English. If it works there, chances are that it is the theme or plugin you are using that is causing the issue, not FilterCodes or Contact for Moodle. As with the Static Pages plugin (see below), you may find that there is a setting that needs to be changed. If not, contact the author/maintainer of the plugin and ask them to add support for filtering in their theme or plugin.
456
 
457
If the form works in English and not in your preferred language, you may need to translate the names of some of your fields. This is required if you want the field names to appear in your language in the email. [More information on Language support](#language-support)
458
#### Sesskey error
459
If you are getting an error that mentions *sesskey*, you may have forgot to include the JavaScript snippet in your form:
460
 
461
    <input type="hidden" id="sesskey" name="sesskey" value="">
462
    <script>document.getElementById('sesskey').value = M.cfg.sesskey;</script>
463
 
464
If you have [FilterCodes](https://moodle.org/plugins/filter_filtercodes/) installed, you can simply replace all of the above code in your form with:
465
 
466
    {formsesskey}
467
 
468
If JavaScript does not work in your form, you can replace the above code with the following HTML. Be aware that it will override one of several anti-spam protections built into Contact Form (requires FilterCodes):
469
 
470
    <input type="hidden" id="sesskey" name="sesskey" value="{sesskey}">
471
 
472
#### Static Pages plugin compatibility
473
 
474
The recommended way of using Contact for Moodle is to create your webmail form in a page or block. However, there may be use cases where you might prefer to use the [local_staticpage plugin](https://moodle.org/plugins/local_staticpage). In order for this to work, you will need to configure a couple of its settings:
475
 
476
* Enable the Static Pages plugin's **Process Filters** (processfilters) setting to enable processing of FilterCodes.
477
* Disable its **Clean HTML code** (cleanhtml) setting to prevent StaticPage from deleting or filtering out some of the required HTML code in your form.
478
 
479
This demonstrates how to use FilterCode Contact Form templates with the Static Pages to create a quick Contact Us form. Start by copying the following code into a text file called contact.html and saving it:
480
 
481
    <html>
482
    <head>
483
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
484
        <title>Contact Us</title>
485
    </head>
486
    <body>
487
        <h1>Contact Us</h1>
488
        {formcontactus}
489
    </body>
490
    </html>
491
 
492
Next, simply upload the contact.html file into Static Pages in order to make it available on your Moodle site.
493
 
494
### All I see is the word "Forbidden" or a blank screen after submitting a form. What should I do?
495
 
496
This plugin has been extensively tested. If you are still getting this error, it is likely that you will need to fix your form and/or enable Moodle debugging. Alternatively you can try the form logged in as a Moodle administrator. This will enable the display of additional diagnostic information.
497
 
498
### Where do emails go when they are submitted on my Moodle website?
499
 
500
Emails are sent to the Support Email address. Logged in as a Moodle administrator, you can find out the email address by going to:
501
 
502
Administration > Site Administration > Server > Support Contact
503
 
504
If the field is empty, take note of the indicated default email address.
505
 
506
### Why are emails submitted on my Moodle website not being delivered?
507
 
508
Make sure Moodle email is working. We recommend test your Moodle email system using the eMailTest plugin:
509
 
510
  https://moodle.org/plugins/local_mailtest
511
 
512
### My site successfully completed the eMailTest process. Why is it still not working?
513
 
514
If you still can't get your web form to work, the problem might be your form. Try using HTML sample form included in the [Usage](#usage) section. Then customize it to meet your needs.
515
 
516
### I am still getting a lot of spam emails through my web form. Can I block certain IP addresses?
517
 
518
There are a couple of ways you can blacklist an IP address. The best way is to add them to your web server settings. Consult your web server documentation for more information. If you don't have access to those settings, Moodle Administrators can add the IP addresses to the Moodle IP Blocker settings. For more information, see:
519
 
520
  https://docs.moodle.org/en/IP_blocker
521
 
522
### Why does the User's IP address ([userip]) says "::1" or 0:0:0:0:0:1 instead showing a real IP address when I receive an email submitted from the form?
523
 
524
::1 and 0:0:0:0:0:1 are the equivalent of 127.0.0.1 (localhost). This should only happen if your web browser is on the same computer as the web server. Otherwise you should be seeing a real IP address.
525
 
526
### Can I include my favourite captcha in a form?
527
 
528
No. Only Moodle's reCAPTCHA will work. See the [Usage](#usage) section for more information.
529
 
530
### Moodle's reCAPTCHA is enabled. Do I need to use it in my Contact forms?
531
 
532
It is not required. However, if you don't want to use it, you must check the `No ReCAPTCHA` checkbox in the plugin's settings.
533
 
534
### Can I add a check box that must be checked, like for accepting the privacy policy, before the user can submit the form?
535
 
536
Absolutely. Information on how to do this will be coming in the future. (Hint: It requires a JavaScript code snippet)
537
 
538
### I have a multilingual Moodle site. Why does the form works in one language but not in the other?
539
 
540
Each language file defines the names of the fields for your form. To make a form work for all languages, change the name of this fields for each language by editing the "field-" strings in the Moodle language editor so that they are all the same ones you used in your form).
541
 
542
### How can I change the names of the fields that appear in the email?
543
 
544
In your form, change the value of "label for=" to the word you want. On the next line, change the id= and the name= to be the same as the one for the "label for=". Finally, if the field was "name", "email", "subject" or "message", you will also need to edit the related "field-*" string in the Moodle language editor.
545
 
546
### What types of web forms should not be implemented using Contact Form?
547
 
548
This plugin is not suitable for any form whose data should not end up in an email inbox. For example, Moodle natively supports several excellent types of forms processors such as Feedback, Survey and Database. Unless your e-commerce solution involves low volume semi-manual process, this could be better handled by applications designed with this in mind. Signing up for mailing list subscriptions should be done through a service such as Aweber, Constant Contact, MailChimp and other similar services.
549
 
550
Note: The mention of any 3rd party product other than Moodle and FilterCodes is not meant as an endorsement or recommendation. They are simply provided as examples.
551
 
552
### How can I make the form only available to logged-in users?
553
 
554
To only display your form for logged-in users, ensure that it is on a Moodle page that is only viewable by logged-in users. User access to pages and blocks is controlled by Moodle, not by this plugin. With that in mind, if you don't include a name and email address field in your form, only registered users who are logged-in to the Moodle site will be able to submit the form. Another option is to use the {if...}{/if...} conditional tags in the FilterCodes plugin to control who can see the form.
555
 
556
### Why is the name and/or email address I entered in a form getting changed when submitted?
557
 
558
This only happens if a user is logged in. In this case, their registered first and last name and email address will be used instead of the name and email address entered in a form.
559
 
560
### Can I include user profile fields and custom profile fields in the email footer and confirmation email message?
561
 
562
Yes. Not all profile fields are available, but you can do it by inserting [FilterCodes](https://moodle.org/plugins/filter_filtercodes/) tags.
563
 
564
### Why does the "Continue" button always take me back to the front page instead of back to the referrer URL?
565
 
566
This may happen in a few situations:
567
 
568
1) If you manually specified a referrer URL in the form instead of using the recommended JavaScript snippet, this can work but the referrer URL must be fully qualified, be from the Moodle site and begin with the address of your front page ($CFG->wwwroot).
569
2) If you try to trick it by manually specifying a URL from a different website, that URL will be ignored and your user will be redirected to the front page.
570
3) If you access the from by manually typing in it's URL or using a bookmark, the continue button will still take you back to the front page since this would result in no referrer URL being available.
571
 
572
### Why do the form <input> fields disappear every time I save my form in Moodle?
573
 
574
ANSWER 1: This will happen if you are using the old TinyMCE editor in Moodle instead of the newer Atto editor. With default settings, the TinyMCE editor would filter out HTML form tags when you went to save it.
575
 
576
The easy solution is to simply switch your preferred editor to the Atto editor, edit and then save your form. The form fields should remain intact. Once you save your form using the Atto editor, you can switch your preferred editor back to TinyMCE and the form will continue to work for everyone. However, if one day you or someone else should you forget and edit the form with the TinyMCE editor, the fields will disappear again.
577
 
578
If, for whatever reason, you really want to use the TinyMCE editor, you can still get it to work but you will need to modify its Moodle Configuration Settings to allow HTML form field tags.
579
 
580
Additional information:
581
 
582
* [Customizing TinyMCE](https://docs.moodle.org/en/TinyMCE_editor)
583
* [TinyMCE settings](https://lmgtfy.com/?q=tinymce+input+field) - You will need to do the research.
584
 
585
ANSWER 2: If you are having problems specifically with the StaticPages plugin, go into its configuration options and set the Clean HTML code to "No, don't clean HTML code". Otherwise the plugin will filter out HTML tags including all your form tags. (thanks to Alex Ferrer for this solution)
586
 
587
### Can I add a form to the Moodle login page?
588
 
589
It is definitely possible. Here is what you need to do:
590
 
591
1. Go to Site administration > Plugins > Authentication > Manage authentication.
592
2. Scroll down to the Instructions field.
593
3. Insert your form in this field.
594
4. Click Save Changes at the bottom of the page.
595
 
596
That's it! Your form will now appear in the section of the page called "Is this your first time here?" on the Moodle login page.
597
 
598
With that said, if what you really want is to have the ability to approve any registration requests on your site, you might be interested in taking a look at the "Email-based self-registration with admin confirmation" plugin. New users complete would then complete the self-registration process. However, before they can gain access to the site, a Moodle Administrator will receive an email and need to approve. You can find the plugin by going to https://moodle.org/plugins/auth_emailadmin
599
 
600
### Are there any security considerations?
601
 
602
There are no known security considerations at this time.
603
 
604
## Other questions
605
 
606
Got a burning question that is not covered here? Checkout the [troubleshooting section of our Wiki](https://github.com/michael-milette/moodle-local_contact/wiki/Troubleshooting). If you still can't find your answer, submit your question in the Moodle forums or open a new issue on GitHub at:
607
 
608
https://github.com/michael-milette/moodle-local_contact/issues
609
 
610
[(Back to top)](#table-of-contents)
611
 
612
# Contributing
613
 
614
If you are interested in helping, please take a look at our [contributing](https://github.com/michael-milette/moodle-local_contact/blob/master/CONTRIBUTING.md) guidelines for details on our code of conduct and the process for submitting pull requests to us.
615
 
616
## Contributors
617
 
618
Michael Milette - Author and Lead Developer
619
 
620
Big thank you to the following contributors. (Please let me know if I forgot to include you in the list):
621
 
622
* geoffreyvanwyk: Fixed links in the documenation (2023).
623
* alexmorrisnz: Add support for an attachment (2023).
624
* HirotoKagotani: Use the system-wide setting for fullname display (2021).
625
* kmoouni: Option to restrict usage of the plugin to logged in users (2017).
626
 
627
Thank you also to all the people who have requested features, tested and reported bugs.
628
 
629
## Pending Features
630
 
631
Some of the features we are considering for future releases include:
632
 
633
* Add ability to specify custom profile fields in the body of the email message.
634
* Option to enable the auto-responder / confirmation message.
635
* Auto-responder will be editable in the plugin's settings.
636
* Add additional examples of web forms to the documentation (see Wiki).
637
* Create a basic form builder.
638
* Make all submitted web form fields available as markup tags that you can insert into your message template.
639
* Add some Moodle logging of sent messages.
640
* Add a Whitelist and Blacklist for email addresses.
641
* Add a Whitelist and Blacklist for email domains.
642
* Add support for form-specific custom autoresponders.
643
* Add support for form-specific custom confirmation message.
644
* Add support to optionally only use autoresponder feature without also sending the main email message.
645
 
646
If you could use any of these features, or have other needs, consider contributing or hiring us to accelerate development.
647
 
648
[(Back to top)](#table-of-contents)
649
 
650
# Motivation for this plugin
651
 
652
The initial development for this project was sponsored by the kind folk at l'Action ontarienne contre la violence aux femmes together with TNG Consulting Inc.
653
 
654
[(Back to top)](#table-of-contents)
655
 
656
# Further information
657
 
658
For further information regarding the local_contact plugin, support or to
659
report a bug, please visit the project page at:
660
 
661
https://github.com/michael-milette/moodle-local_contact
662
 
663
[(Back to top)](#table-of-contents)
664
 
665
# License
666
 
667
Copyright © 2016-2024 TNG Consulting Inc. - https://www.tngconsulting.ca/
668
 
669
This file is part of the Contact Form plugin for Moodle - https://moodle.org/plugins/local_contact/
670
 
671
Contact Form is free software: you can redistribute it and/or modify
672
it under the terms of the GNU General Public License as published by
673
the Free Software Foundation, either version 3 of the License, or
674
(at your option) any later version.
675
 
676
Contact Form is distributed in the hope that it will be useful,
677
but WITHOUT ANY WARRANTY; without even the implied warranty of
678
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
679
GNU General Public License for more details.
680
 
681
You should have received a copy of the GNU General Public License
682
along with Contact Form.  If not, see <https://www.gnu.org/licenses/>.
683
 
684
[(Back to top)](#table-of-contents)