elegant themes

Disclaimer popups before sending an email or submitting a comment using simple jQuery in WordPress

| March 28, 2012 | 3 Comments

Several of our clients requested that we add popup disclaimers before someone sends an email to the site admin or before they submit a comment. Here’s a screenshot of what we’re going to do:

Case 1: Add a Contact Us link to the navigation menu that triggers a disclaimer popup.  
Once a visitor clicks OK, open the visitor’s email client using the mailto: function.

  1. In the WordPress dashboard, go to Appearance > Menus and add a custom link. 
     
  2. Go to Screen Options and make sure the “CSS Classes” checbox is checked
  3. In the URL field, put mailto:youremail@yoursite.com 
  4. In the CSS Class, put show-confirm-popup
  5. Open up header.php
  6. Check to see if you already have the jQuery library loaded on your site. If not, add the following somewhere between the opening and closing head tags 
  7. Add the following code between the opening and closing head tag. Make sure to change the text of the disclaimer.

  Case 2: Add the popup disclaimer to any link.  

  1. Add the following link structure anywhere on your site.
  2. Copy the code from Step 6 and 7 from Case 1 above into header.php.

Case 3: Add the popup disclaimer before a comment is submitted

  1. Open Comments.php
  2. Do a search for the word “submit”
  3. Add the onClick parameter to the Submit button. It will look something like this:
  4. Copy the code from Step 6 and 7 from Case 1 into header.php and also in header.php, add the following function. Remember to change the text.

     

Big thank you to Elisha!

Tags: , , , , ,

Category: Code Snippets

About Rebecca Markowitz: Rebecca Markowitz has built over 50 WordPress sites for clients as Web Project Manager and WordPress specialist at illuminea. illuminea is a Jerusalem-based boutique web agency. WPGarage shows my dedicated relationship with WordPress over the years - full of love, laughs, tears, growth and strong drinks. L'chaim! View author profile.


Comments (3)

Trackback URL | Comments RSS Feed

  1. Ed Boress says:

    Many thanks for the info.  Big help.

  2. [...] little article that explains how to use jQuery to create popups before sending an email or submitting a [...]

  3. [...] Disclaimer popups before sending an email or submitting a comment using simple jQuery in WordPress (WP Garage) [...]

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.

More in Code Snippets (6 of 34 articles)