=== Google Forms === Contributors: mpwalsh8 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DK4MS3AA983CC Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms Requires at least: 4.0 Tested up to: 4.9.8 Stable tag: 0.95 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Embeds a published, public Google Form in a WordPress post, page, or widget. == Description == Fetches a published Google Form using a WordPress custom post or shortcode, removes the Gooogle wrapper HTML and then renders it as an HTML form embedded in your blog post or page. When using Google Form post type, the *wpgform* shortcode accepts one parameter, *id*, which is the post id of the form. When using the __deprecated__ *gform* shortcode, the only required parameter is `form` which is set to the URL to the Google Form URL. Recommended but optional, you can also provide a custom URL for a confirmation page if you don't care for the default Google text. The confirmation page will override the default Google `Thank You` page and offers better integration with your WordPress site. There are a number of other options, refer to the documentation for further details. For example, suppose you want to integrate the form at `https://docs.google.com/spreadsheet/viewform?hl=en_US&pli=1&formkey=ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678#gid=0`, (not a real URL) use the following shortcode in your WordPress post or page: [wpgform id='861'] [gform form='https://docs.google.com/spreadsheet/viewform?hl=en_US&pli=1&formkey=ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678#gid=0'] __Deprecated:__ use of the *gform* shortcode is __deprecated__ - please use the *wpgform* shortcode. Currently, this plugin only supports Google Forms that are "Published as a web page" and therefore public. Private Google Forms are not supported. [Demo](http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/) == Installation == 1. Install using the WordPress Pluin Installer (search for `WordPress Google Form`) or download `WordPress Google Form`, extract the `wpgforms` folder and upload `wpgforms` to the `/wp-content/plugins/` directory. 1. Activate the plugin through the 'Plugins' menu in WordPress. 1. Configure `WP Goolge Forms` from the `Settings` menu as appropriate. 1. Recommended: Create a Google Form Custom Post Type and then use the `[wpgform id='']` shortcode wherever you'd like to insert the Google Form or simply publish the form and use it's permalink URL. 1. Alternatively: Use the `[gform form='']` shortcode wherever you'd like to insert the Google Form. == Usage == As features have been added, usage of the `gform` shortcode has grown increasing complex (the `gform` shortcode is now *deprecated*). Begining with v0.46, a second shortcode, `wpgform` has been introduced in conjunction with a Custom Post Type to define forms deprecating usage of the `gform` shortcode. Usage of the new shortcode and Custom Post Type is much, much easier than the complexities of the original `gform` shortcode. Users are strong encouraged to migrate usage to the new shortcode and Custom Post Type. New features will only be added to the Custom Post Type usage model. The WordPress Google Form shortcode `wpgform` supports a single attribute. The rest of the controls are derived from the information stored with the Custom Post Type. `[wpgform id='' uid='']` *NOTE:* In the above syntax, values enclosed in angle brackets <>, indicate a string you need to replace with an appropriate value. Do not include the angle brackets in your string! * __id__: The numeric id of the Google Form Custom Post Type. * __uid__: A unique string (e.g. 'A-') used to ensure form element ID attributes are unique when a form appears on a page multiple times. (optional) The Google Form *deprecated* shortcode `gform` supports a number of attributes that allow further control and customization of the Google Form. `[gform form='' confirm='' class='' legal='on|off' br='on|off' prefix='' suffix='' email='on|off' sendto='' style='redirect|ajax' spreadsheet='' unitethemehack='on|off']` *NOTE:* In the above syntax, values enclosed in angle brackets <>, indicate a string you need to replace with an appropriate value. Do not include the angle brackets in your string! * __form__: The full URL to the published Google Form. You must be able to open this URL successfully from a browser for the __gform__ shortcode to work properly. * __confirm__: A full URL to the confirmation (e.g. _Thanks for your submission!_) page. Be default Google displays a very basic confirmation page which cannot be integrated easily with your WordPress site. The _confirm_ attribute allows the form submission to land on a page of your choosing. **It is strongly encouraged that you make use of a confirmation page.** It will make the form submission process cleaner and clearer to the end user. The confirmation page will be displayed by a page redirect unless a different behavior is specified using the __style__ attribute. * __style__: Specify how the custom confirmation page should be presented. Legal values for the __style__ attribute are __redirect__ and __ajax__ (e.g. __style='redirect'__ or __style='ajax'__). * __alert__: A message to display upon successful form submission in a Javascript Alert box (e.g. _Thanks for your submission!_). * __class__: Google Forms are full of classes but the WordPress Google Form plugin does not bring their definitions into page when importing the form. The _class_ attribute allows the addition of one or more CSS classes to the DIV which wraps the Google Form. To add multiple classes, simply separate the class names with spaces. * __legal__: By default Google Forms have a _Powered by Google Docs_ section at the bottom of the form which includes links to Google TOS and other Google information. If you do not want to see this information as part of the form, add `legal='off'` to your shortcode usage. The content remains in the form, it is simply hidden from the end user using CSS. * __br__: For a <br> tag to be inserted between the form label and the input text box by setting the *br* attribute to *on*. This will result in the form label and the input box being stacked on top of one another. * __prefix__: Google Forms make use 20+ CSS classes. If you use multiple forms and want to style them each differently, you can add a _prefix_ which will be added to beginning of each class name used in the Google Form. * __suffix__: Append a character string to the end of each form label. This can also be accomplished using CSS, refer to the CSS section. * __title__: By default Google Forms have title wrapped in a <h1> tag. If you do not want to include this form title as part of the form, add `title='off'` to your shortcode usage. The <h1> content is removed from the form. * __maph1h2__: By default Google Forms have title wrapped in a <h1> tag. If you want the form title but not as an <h1> element, add `maph1h2='on'` to your shortcode usage. The <h1> elements will be mapped to <h2> elements. The CSS class attributes remain unchanged. * __email__: Notify the site's WordPress administrator (or sendto email address) that a form has been submitted by setting the __email__ attribute to __on__. This will result in an email being sent to the blog administrator (or sendto email address) letting them know a form was submitted with the URL of the form along with the date and time of submission. * __sendto__: Notify the "sendto" email address that a form has been submitted by setting the __email__ attribute to __on__. This will result in an email being sent to the "sendto" letting them know a form was submitted with the URL of the form along with the date and time of submission. The email message will always be sent to the blog administrator via Bcc. * __spreadsheet__: The full URL to the "Shared" Google Docs Spreadsheet which stores the form responses. You must be able to open this URL successfully from a browser for the link in the email to work properly. This attribute is used in conjunction with the __email__ attribute, it has no effect when the __email__ attribute is not turned __on__. * __unitethemehack__: Off by default, this attribute should be enabled, `unitethemehack='on'`, when using the [Unite theme from Paralleus](http://themeforest.net/item/unite-wordpress-business-magazine-theme/90959). The Unite theme manipulates the submit button(s) on a page, the result of which is a button that prevents the Google form from being submitted. Turning this attribute on enables a hack which inserts *class="noStyle"* to all submit buttons, preventing Unite from mucking with them. * __validation__: Off by default, this attribute can be enabled, `validation='on'`, to add jQuery based form validation support using the [jQuery Validate Plugin](http://bassistance.de/jquery-plugins/jquery-plugin-validation/). Enabling this optional attribute will allow inline checking without form submission to Google (which also does checking for required fields). Error messages can be styled using the *gform-error* CSS class. * __captcha__: Off by default, this attribute can be enabled, `captcha='on'`, to add a simple math based [CAPTCHA](http://en.wikipedia.org/wiki/CAPTCHA) to the Google Form. The CAPTCHA only appears for the final submit on multi-page forms. The CAPTCHA error message can be styled using the *gform-error* CSS class. * __columns__: The number of columns the form should be split into. By default the form appears in a single column the same way it is designed in Google Docs. `[gform form='https://docs.google.com/spreadsheet/viewform?hl=en_US&pli=1&formkey=ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678#gid=0' confirm='http://www.example.com/thankyou/' style='ajax' class='mygform' legal='off' prefix='mygform-' br='on' title='on' maph1h2='on' email='on' spreadsheet='https://docs.google.com/spreadsheet/ccc?key=0AgBHWDGsX0PUdE56R1ZldXo4a0N3VTNMNEpSemdGV3c' unitethemehack='off' validation='on' captcha='on' columns='1']` == License == This plugin is available under the GPL license, which means that it's free. If you use it for a commercial web site, if you appreciate my efforts or if you want to encourage me to develop and maintain it, please consider making a donation using Paypal, a secured payment solution. You just need to click the donate button on the the [plugin overview page](http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/) and follow the instructions. == Frequently Asked Questions == = Why I do I have a "cURL transport missing" message on my Dashboard? = There was a change to the WordPress HTTP API in version 3.7 which resulted in wp_remote_post() no longer working with the streams and fsockopen transports when posting form data back to Google Docs. The cURL transport does work reliably so a check has been added and a notification is issued when the cURL transport is missing. This notification can be hidden by selecting the proper checkbox on the plugin settings page. = Will the plugin work without the cURL transport? = Up until WordPress 3.6.1, the plugin worked with any of the supported transports (streams, fsockopen, curl). Currently only cURL is known to work properly. You may have some success with other transports IF your form does not include checkboxes. Checkboxes definitely do not work with anything but the cURL transport. = How can I add the cURL transport to WordPress? = The cURL transport is enabled by WordPress when PHP support for cURL is detected. It isn't something which can be added to WordPress, it needs to be present in the PHP version your web server is running. Contact your hosting provider to inquire about adding cURL support to PHP for your WordPress site. = The default style is ugly. Can I change it? = Yes, there are two ways to change the style (aka apearance) of the form. 1. By adding the necessary CSS to your theme's style sheet. 1. Through the WordPress Google Form custom CSS setting. Google Forms include plenty of [CSS](http://en.wikipedia.org/wiki/Cascading_Style_Sheets) hooks. Refer to the **CSS** section for further details on styling the form. There are also some CSS solutions posted to questions users have raised in the Tips and Tricks section of [this page](http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/tips-and-tricks/). = Why are the buttons and some other text on form in Chinese (or some other language)? = This problem occurred fairly infrequently with the older version of Google Forms but with the upgrade in early 2013, it seems to happen much more often. The solution to this problem depends on which URL format your published Google Form takes on (old or new). If your form URL looks like this, then you are using the older version of Google Forms: `https://docs.google.com/spreadsheet/viewform?formkey=dE56R1ZldXo4a0N3VTNMNEpSemdGV3c6MQ#gid=0` To force the language to English, you need to include the parameter **hl=en**. Placement doesn't matter except it must appear before the #gid=0 (or similar syntax depending on which sheet you're using). You will either need to prefix or append the & character to ensure the parameter is passed correctly. `https://docs.google.com/spreadsheet/viewform?formkey=dE56R1ZldXo4a0N3VTNMNEpSemdGV3c6MQ&hl=en#gid=0` If your form URL looks like this, then you are using the new version of Google Forms: `https://docs.google.com/forms/d/1iQndtNhFFiLHPdTpvuYKifdsxN7XQSFa9D8CsTU8aTc/viewform` To force the form to use English you would append **"?hl=en"** to the URL so it looks like this: `https://docs.google.com/forms/d/1iQndtNhFFiLHPdTpvuYKifdsxN7XQSFa9D8CsTU8aTc/viewform?hl=en` You can find an [example Google Form with French buttons](http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/sample-form-in-french/) on the plugin web site. = Why do I get a 403 error? = There a number of reasons to get a 403 error but by far the most common one encountered so far is due to ModSecurity being installed by your web hosting provider. Not all providers deploy ModSecurity but enough do that it comes up every once in a while. If your provider is running ModSecurity and your version of the plugin is v0.30 or lower, you will likely see odd behavior where when the form is submitted, the page is simply rendered again and the data is never actually sent to Google. There isn't any error message to indicate what might be wrong. Version 0.31 fixes this problem for *most* cases but there is still a chance that it could crop up. If your provider has enabled ModSecurity AND someone answers one of the questions on your form with a URL (e.g. http://www.example.com), then very likely ModSecurity will kick in an issue a 403 error. The plugin is now smart enough to detect when the error is issued and let you know what is wrong. Unfortunately there isn't currently a solution to allow URLs as responses when ModSecurity issues a 403 error. Some themes filter page content which could potentially affect forms. If the filter modifies the Google Form HTML in such a way (e.g. changing the value of a hidden form variable) such that it is different that what Google is expecting upon form submission, a 403 error may result. = No matter what I do, I always get the "Unable to retrieve Google Form. Please try reloading this page." error message. Why is this? = 1. The most common reason for this error is from pasting the Google Form URL into the WordPress WYSIWYG Editor while in "Visual" mode. When you paste the URL, the Visual Editor recognizes at a link and wraps the text in the apprpriate HTML tags so the link will work. Visually you'll trypically see the URL in a different color than the rest of the short code text. If this happens, simply click anywhere in the link and use the "Break Link" icon (broken chain) on the tool bar to remove the link. The other alternative is to toggle to HTML mode and manually remove the HTML which is wrapped around the URL. 1. Validate that the WordPress HTTP API is working correctly. If you are seeing HTTP API errors on the WordPress Dashboard or when you attempt to access the plugin repository through the Dashboard, the WordPress Google Form will likely fail too. It requires the WordPress HTTP API to be working. With some free hosting plans, ISPs disable the ability to access remote content. = Do you have a demo running? = Yes, see a demo here: [Demo of WordPress Google Form plugin](http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/) Feel free to submit a response and then view other responses as well. = Content appears, but it's not my form and it looks odd! Why? = You should triple-check that you've published your Form. Google provides instructions for doing this. Be sure to follow steps 1 and 2 in [Google Spreadsheets Help: Publishing to the Web](http://docs.google.com/support/bin/answer.py?hl=en&answer=47134) as the same process applies to Forms and Spreadsheets. = Why doesn't my form look the same as it does when I use the stand alone URL? = Google Forms can have _Themes_ which are really nothing more than CSS defitinions to change the form's appearance. None of the Google CSS is brought into WordPress, just the CSS class names and the HTML used to define the form. Refer to the **CSS** section for more information on styling your form. = Google supports embedding forms, why isn't that sufficient? = For many uses the simple embedding of a Google Form in an `