WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Google Forms

Embeds a published, public Google Form in a WordPress post, page, or widget.

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='<Google Form CPT Id>' uid='<unique text string>']

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='<full_url_to_Google_Form>' confirm='<full_url_to_confirmation_page>' class='<value>' legal='on|off' br='on|off' prefix='<value>' suffix='<value>' email='on|off' sendto='<email address>' style='redirect|ajax' spreadsheet='<full_url_to_Google_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. 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. 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 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 and follow the instructions.

CSS

Google Forms make use of 20+ CSS class definitions. By default, the WordPress Google Form plugin includes CSS declarations for all of the classes however the bulk of them are empty. The default CSS sets the font and makes the entry boxes wider. The default CSS that ships with WordPress Google Form can optionally be turned off via the WordPress Google Form settings.

Customizing Google Form CSS

There are two ways to customize the Google Form CSS.

  1. The WordPress Google Form plugin includes a setting to include custom CSS and a field where custom CSS can be entered. This CSS will be preserved across themes.
  2. Add custom CSS declarations to your WordPress theme.

Default Google Form CSS

As of 2013-12-04, the following is are the CSS classes which Google Forms make use of. The CSS below represents the default CSS provided by WordPress Google Form. These CSS definitions can be copied and pasted into your theme CSS or the WordPress Google Form custom CSS setting and changed as desired. Some of the classes are redundant to account for both the new and old style of Google Forms.

/* vim: set expandtab tabstop=4 shiftwidth=4: */
/**
 * CSS declarations for Google Docs Forms
 *
 * These can be copied and modified to fit the needs of
 * a theme.  By default the only change is to make all of
 * the fields wider than their default width and to set the
 * default font.
 */

label.gform-error,
label.wpgform-error {
    float: right;
    color: red;
    font-weight: bold;
}

div.gform-captcha,
div.wpgform-captcha {
    margin: 5px 0px 10px;
    display: none;
}

div.gform-browser-warning,
div.gform-browser-error,
div.wpgform-browser-warning,
div.wpgform-browser-error {
    -webkit-border-radius: 3px;
    border-radius: 3px;
    border-width: 1px;
    border-style: solid;
    padding: 0 .6em;
    margin: 5px 0 15px;
}

div.gform-browser-warning,
div.wpgform-browser-warning {
    background-color: #ffffe0;
    border-color: #e6db55;
}

div.gform-google-error,
div.gform-browser-error,
div.wpgform-google-error,
div.wpgform-browser-error {
    background-color: #ffebe8;
    border-color: #cc0000;
}

body.ss-base-body {}
div.errorbox-good {}
div.ss-attribution {}
div.ss-footer {}
div.ss-footer-txt, div.ss-logo {
    display: none;
}

div.ss-form {}
div.ss-form-container {
    font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}
div.ss-form-desc {}
div.ss-form-entry {}
div.ss-form-entry>input {
    background-color: #e0e0e0;
    font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}
div.ss-form-heading {}
div.ss-item {}
div.ss-legal {}
div.ss-navigate {}
div.ss-no-ignore-whitespace {
    white-space: pre-wrap;
}
div.ss-required-asterisk {
    color: red;
    font-weight: bold;
}
div.ss-scale {}
div.ss-text {}
form#ss-form {}
h1.ss-form-title {}
hr.ss-email-break {}
input.ss-q-short:text {
    width: 300px;
}
label.ss-q-help {
    display: block;
}
label.ss-q-radio {}
label.ss-q-title {
    font-weight: bold;
}
span.ss-powered-by {}
span.ss-terms {}
td.ss-gridnumber {}
td.ss-gridnumbers {}
td.ss-gridrow
td.ss-gridrow-leftlabel
td.ss-leftlabel {}
td.ss-rightlabel {}
td.ss-scalerow {}
td.ss-scalenumber {}
td.ss-scalenumbers {}
textarea.ss-q-long {
    background-color: #e0e0e0;
    font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}
tr.ss-gridrow {}

/**
 * New Google Forms CSS 2013-04-30
 */

div.ss-form-container div.disclaimer {
    display: none;
}

div.ss-q-help {
}

div.ss-secondary-text {
}

/*  This hides the "Never submit passwords through Google Forms." warning. */
td.ss-form-entry > div.ss-secondary-text {
    display: none;
}

div.password-warning {
    display: none;
}

div.ss-form-container li {
    list-style-type: none;
}

/*  2013-06-04:  Hide "Edit this Form" link */
a.ss-edit-link {
    display: none;
}

/*  2013-06-06:  Hide help text for scales */
div.aria-only-help {
    display: none;
}

/* 2013-10-30:  Hide default error messages */
div.error-message {
    display: none;
}

/* 2013-10-30:  Attempt to make text entry boxes a reasonable width */
input.ss-q-short, textarea.ss-q-long {
    width: auto;
}

/* 2013-11-15:  CSS to support using WordPress Google form to render spreadsheets */

/**  Hide the gunk that Google adds to make the table work **/
td.hd, td.headerEnd, tr.rShim, td.sortBar {
    display: none;
    width: 0px !important;
    padding: 0px !important;
}

/**  Empty selector but could be used to select all of the table cells **/
tr.rShim td, tr.rShim ~ tr td {
}

/**  Hide the "powered" and "listview" DIVs that Google adds **/
div div span.powered, div.listview {
    display: none;
}

/** Hide the "This is a required question" message **/
div.ss-form-container div.required-message {
    display: none;
}

Requires: 3.7.1 or higher
Compatible up to: 3.9.2
Last Updated: 2014-7-7
Downloads: 117,222

Ratings

4 stars
4.9 out of 5 stars

Support

8 of 18 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,2,2
75,4,3 100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,2,2 0,1,0
100,1,1
33,3,1
50,2,1
0,1,0
0,2,0 0,1,0