Forms Wordpress Plugin - Rating, Reviews, Demo & Download
Plugin Description
This plugin is developed at
Shepherd Interactive
for the benefit of the community. No support is available. Please post any questions to the support forum.
Allows forms to be written with new HTML5 input type and validation attributes, and
then to have them validate themselves server-side: DRY forms (don’t repeat yourself).
Forms are embedded into posts via the form
shortcode. Results can be automatically emailed.
A web form is defined in a PHP function that returns an entire form element, for example:
function my_contact_form($attrs, $content = null){
ob_start();
?>
<form method="post">
<p hidden="hidden" class="form_error_message"></p>
<p>Name: <input type="text" required="required" name="contact_name" maxlength="255" placeholder="Jo Smith" autofocus="autofocus" /></p>
<p>Email: <input type="email" required="required" name="contact_email" maxlength="255" placeholder="jsmith@example.com" /></p>
<p>Message: <textarea required="required" name="contact_message" maxlength="1000" placeholder="Enter your message here"></textarea></p>
<p><button type="submit">Submit</button></p>
</form>
<?php
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
And this form can be embedded into a post by entering [form name="my_contact_form"]
.
Here are the shortcode options:
name
email_to
email_cc
email_bcc
email_subject
success_url
success_page_id
cc_sender
default:false
email_type
default: (HTML)table
: other optionsdl
,text
,form
These options may also be specified via Custom Fields (postmeta):
form_name
form_email_to
form_email_cc
form_email_bcc
form_email_subject
form_success_page_id
form_success_url
form_email_type
Many filters and actions are available. Please see the source code.
When the form is submitted and the server determines that user data is invalid, then the server will respond with 400 Invalid Request.
In the 400 response, the page containing the form is returned and the form repopulated with the user’s original request with
class names and data-
attributes that describe the errors on an invalid element.
If the server successfully validates the form, then the user will be redirected to success_url
or success_page_id
if they are provided.
Please see source code for full documentation.
Handling File Inputs
Files are uploaded to /wp-content/uploads/
(or whatever this is specified to
be in your install), unless filtered to be something different via
form_file_upload_path filter, or if the data-upload-path
attribute is set on
the file input
element, for example:
<input type="file" data-upload-path="<?php
$uploadDir = wp_upload_dir();
echo esc_attr(parse_url(trailingslashit($uploadDir['baseurl']) . 'form-submissions/', PHP_URL_PATH));
?>" name="my_image" pattern=".+.(jpe?g|gif|png)" />
The upload path is appended to the ABSPATH
,
and it must be within the /wp-content/uploads/
directory (or
equivalent) or a security exception will be raised. When the server fails to
move the file or if it is too big or if some other error occurs (e.g. directory
not writable), then the form submission will respond with a 500 error and the
file control will be marked as invalid customError
and the specific
error will be included on the data-validationMessage
attribute.
Screenshots
No screenshots provided