Quantcast
Channel: Support – Jetpack
Viewing all articles
Browse latest Browse all 371

Contact Form (Classic Editor)

$
0
0

Note: These instructions are for the Classic Editor, and sites running WordPress 4.9.10 or older.

If you are using the new Gutenberg editor in WordPress 5+, please refer to the instructions for adding a form block instead. 

How to Create a Contact Form

While editing a post or page, click the Add Contact Form button.

Note: If you do not see the Add Contact Form button, you need to turn on the Contact Form feature.

Add a Contact Form

The form will be inserted directly into your content:

inserted form

Handling the Form Results

You will receive an email notification for each contact form response (provided your WordPress email sending is working). All responses will also be listed in the Feedback section of the site’s WP Admin.

Click on the form and choose the pencil icon to edit it:

edit form

There, you can adjust all of the form’s settings, including the email address it’s sent to, the subject, and all form fields:

edit form settings

If you have the Akismet plugin installed and activated and have an active subscription, every form submission will be checked for spam.

embedded form

Adding a Contact Form with Shortcodes

You can add a basic contact form using a WordPress specific code called a shortcode. You can read more about shortcodes here.

To add a contact form using a shortcode, copy and paste the text below to any post, page, or text widget:

[contact-form]
[contact-field label="Name" type="name" required="true" /]
[contact-field label="Email" type="email" placeholder="Your Email Address" required="true" /]
[contact-field label="Website" type="url" /]
[contact-field label="Comment" type="textarea" required="true" /]
[/contact-form]

You can find more details and the full list of available contact for shortcode attributes here.

Pre-fill Form Fields with URL Parameters

You can create custom links to send visitors to a form that is pre-filled with default information. To do this, you’ll need to get the name of the form field, which will include the post or page ID and the field name that you assigned in the form editor. To create a link:

  1. Create the form, as described above.
  2. Open the page/post containing the form and use your browser’s Element Inspector to locate the field ID of the field you want to pre-fill. It will look something like this: id="g12249-name"
  3. Now you can append that field to the URL for the form page, and add the pre-filled entry by adding a ? after the URL and an = after the field ID, followed by the entry. So it will look something like this: https://yourjetpack.blog/contact-form?g12249-name=Jetpack
  4. If you’d like to pre-fill multiple fields, you can use & between fields: https://yourjetpack.blog/contact-form?g12249-name=Jetpack&g12249-name=support@jetpack.com
  5. You can then use this link wherever you like, and anyone who clicks it will see the pre-filled form rather than the default form. The form functionality will remain the same.

Tips for Using Your Form

 

Add to Pages, Posts, or Widgets.

Contact forms can be added to pages or posts, or if you copy the generated code, you can add your contact form to a text widget.

Forms are customizable.

Contact forms can be customized. You can add and remove fields, choose which fields are required, change the email address, or change the subject settings. The form’s appearance can be further customized with CSS.

Edit an existing form.

To edit an existing form, edit the post or page from WP Admin, then click “Add Contact Form.”

  • One per page – Each post, page, and text widget will only display one contact form.

 

One per page.

Each post, page, and text widget will only display one contact form.

Remember, email is not secure.

Do not use contact forms for sensitive information like credit card numbers, as the information will be transmitted by email.

Built-in spam filter.

e filter submissions through Akismet to fight spam, then add them to your feedback menu, which is accessible to Editors and Administrators on your site. We also email a copy to you.

Customization

 

Change the Success Message.

If you like, you can show a custom message after your form has been submitted. The grunion_contact_form_success_message filter allows you to specify a custom success message on each one of the forms on your site.

The sample code below allows you to customize the message for a form added to a specific page as well as define a generic message for all other forms.

This code should be added to your WordPress theme’s functions.php file. An easy and safe way to do this is by using the Code Snippets plugin.

function jetpackcom_contact_confirmation() {
	if ( is_page( '10' ) ) {
		$conf = __( 'A special confirmation message for the form you added to page 10', 'plugin-textdomain' );
	} else {
		$conf = __( 'A generic confirmation message to display for all the other forms', 'plugin-textdomain' );
	}
	return $conf;
}
add_filter( 'grunion_contact_form_success_message', 'jetpackcom_contact_confirmation' );
Customize the Submit Button.

If you like, you can show a custom message after your form has been submitted. The grunion_contact_form_success_message filter allows you to specify a custom success message on each one of the forms on your site.

The sample code below allows you to customize the message for a form added to a specific page as well as define a generic message for all other forms.

This code should be added to your WordPress theme’s functions.php file. An easy and safe way to do this is by using the Code Snippets plugin.

[contact-form submit_button_text='YOUR CUSTOM SUBMIT BUTTON TEXT HERE'][contact-field label='Name' type='name' required='1'/][contact-field label='Email' type='email' required='1'/][contact-field label='Website' type='url'/][contact-field label='Comment' type='textarea' required='1'/][/contact-form]

Redirect Readers to a Specific Page After Submission.

If you want, you can redirect your readers to a specific page on your site after submitting the form. For example, readers could be redirected to a page where they can claim a prize after providing you with their contact information.

To create that redirection, we’ll use the grunion_contact_form_redirect_url filter:

/**
 * Jetpack Contact Form Custom Redirections.
 *
 * @param  string $redirect Post submission URL.
 * @param  int    $id       Contact Form ID.
 * @param  int    $post_id  Post ID.
 *
 * @return string $redirect Custom Post submission URL.
 */
function jetpackcom_custom_form_redirect( $redirect, $id, $post_id ) {
    /**
     * Create a list of pages where you've inserted forms.
     * For each contact Form ID (found via the id attribute on the form),
     * set up a custom URL where the user will be redirected.
     */
    $redirects = array(
        '1370' => home_url( 'page_on_your_site' ),
        '2239' => home_url( 'another_page' ),
        '1370' => home_url( 'page_on_your_site' ),
    );
 
    // Let's loop though each custom redirect.
    foreach ( $redirects as $origin => $destination ) {
        if ( $id == $origin ) {
            return $destination;
        }
    }
 
    // Default Redirect for all the other forms.
    return $redirect;
}
add_filter( 'grunion_contact_form_redirect_url', 'jetpackcom_custom_form_redirect', 10, 3 );
Customize the Notification Emails.

Jetpack allows you to customize the fields you add to the contact form, and also offers an option to change the subject of the email sent to you after each form submission.

You can add tokens to the subject field, like {city}, and Jetpack will replace the token with the value of the “City” form field (case insensitive, just make sure that the words match).

Troubleshooting

I don’t see the form interface, I only see code!

If you don’t see the form interface described above, make sure that you’re in the editor’s Visual tab and not the Text tab, from the top-right of the editor.

If you don’t see the Visual and Text tabs as described, go to Users > Your Profile in your site’s Dashboard and uncheck “Disable the visual editor when writing.”

The form interface will only work in the editor’s Visual tab.

I’m not receiving notification emails about my form submissions!

Jetpack, like other contact form plugins, uses a function named wp_mail() to send out emails. It’s the same function that is used by WordPress to send you comment notifications or notifications about new users registering on your site.

You can check if that function works properly by leaving a comment on your site and checking if you receive an email. Another alternative would be to use the Email Logs plugin. This plugin records a log of all e-mails sent out by WordPress once it is activated. If an email is listed in this plugin’s logs and you do NOT receive it, then the issue is likely either with your server or the recipient’s server.

If you find issues with that function, you could use an SMTP plugin to configure your WordPress installation to use a specific email service to send out emails.

If the function appears to be work properly, it means that Jetpack’s emails are being filtered out before they can reach your inbox. A few possibilities:

  • They can be filtered out by your server before they even get sent out. Your hosting provider should be able to check their server email logs to find out if the emails were blocked.
  • They can be filtered out by your email provider. If you don’t find the emails in your spam folder, you’ll want to try sending out Jetpack emails to another email address and see if you keep experiencing issues.

If none of this helps, contact support for assistance.

Privacy Information

This feature is activated by default, although it does require a site author to explicitly add a contact form to a published post or page on the site. While there are no controls for it within the primary Jetpack settings area, it can be deactivated any time by following this guide.

More information about the data usage on your site
Data Used
Site Owners / Users

For activity tracking (detailed below): IP address, WordPress.com user ID, WordPress.com username, WordPress.com-connected site ID and URL, Jetpack version, user agent, visiting URL, referring URL, timestamp of event, browser language, country code.

Site Visitors

If Akismet is enabled on the site, the contact form submission data (IP address, user agent, email address, site URL, and comment) is submitted to the Akismet service (also owned by Automattic) for spam checking.The actual submission data is stored in the database of the site on which it was submitted and is emailed directly to the owner of the form (i.e. the site author who published the page on which the contact form resides). This email will include the submitter’s IP address, timestamp, name, email address, website, and message.

The IP address is included as an abuse prevention measure. And for sites using Akismet, it is required for providing proper spam defense.

Activity Tracked
Site Owners / Users

We track when, and by which user, the feature is activated and deactivated.

Site Visitors

None.

Data Synced (Read More)
Site Owners / Users

We sync a single option that identifies whether or not the feature is activated.

Site Visitors

We sync post and post metadata associated with a user’s contact form submission. If Akismet is enabled on the site, the IP address and user agent originally submitted with the comment are synced, as well, as they are stored in post meta.


Viewing all articles
Browse latest Browse all 371

Trending Articles