A couple of days ago I was chatting to Darren over at My Life in Leeds (running WordPress) and he asked if I knew a way that a visitor to his site could report changes to the factual content of articles. Darren publishes reviews of Leeds’ businesses and attractions and should one business change its name, close down or move address, the information provided becomes either outdated or stale. So a way for site visitors to quickly submit a correction seems like a sensible addition to any review website.
Darren was in two minds whether to open up comments on posts and although that would certainly do the trick, maybe something more suitable could be deployed. I like a challenge so I put my mind to it yesterday and came up with a reasonably simple solution.
The simplest way to add functionality to WordPress is via plugins. I suppose it’s not the purist’s way but it’s just easy. So I decided that I’d start hunting around for plugins that could do the job. These are the ones I came up with:
Simple Content Reveal
This plugin does what it says on the tin. Its author David Artiss describes it thus:
Simple Content Reveal allows you to easily hide and reveal WordPress content, whether it be in the sidebar or in a post or page.
Contact Form 7
This is a widely used contact plugin and yet most users don’t really explore its full potential. It comes with lots and lots of shortcodes you can add-in to both the submission form and the resultant email.
Putting the Two Together
You can see the two plugins working together to achieve the desired result on my testing site1. This first image (click it for a larger version) shows some dummy text at the end of a post. After the text you can see Simple Content Reveal in action, in its default closed state:
This second image shows what happens when you click the text or icon. Contact Form 7 is revealed:
So How Do I Get The Same
First of all install the two plugins.
Then you need to set up a contact form. Go to the Contact settings area in your WordPress Dashboard (it has its own menu entry on the left) and create a new form. Here are the settings in my example:
<p>Your Name (required)<br /> [text* your-name] </p> <p>Your Email (required)<br /> [email* your-email] </p> <p><br /> [select menu-642 "Bar is closed" "Bar has new name" "Bar sells watered down beer" "The world is about to end" "Where's the cheese?" "Other..."]</p> <p>Details<br /> [textarea textarea-838]</p> <p>[submit "Send"]</p>
There’s no need for a subject because we’re going to use the form’s selected option as the subject of the email and use a feature of Contact Form 7 that picks up the Post Title and Post URL then includes them in the form submission:
Dear Dave [your-name] has submitted a post report regarding: [_post_title] They want to tell you that: [menu-642] [textarea-838] You can see it here: [_post_url] -- This mail is sent via contact form on Caramboo Testing http://testing.caramboo.com
Once that’s all set up, go to a post where you want the form to be active and at the end, put something like this (obviously edit for your own use, your form title may be different etc)
%image%Report a change in this entry" id="id2"] [contact-form 2 "Post Reporting"] [reveal]
Once done, and provided you set up the contact form properly, you should have the hide/reveal working and people can report on your post page by clicking the link. If someone completes the form you should get an email containing their report together with the Post Title and URL.
I realise that a more elegant way to insert the three lines at the end of every >post would be to use PHP within your theme templates. In this example I chose just to use the shortcodes entered in the WordPress editor to keep things simple. I’ll do a further post explaining how to suitably edit your templates.
The eagle eyed amongst you will have spotted that I’ve got a similar thing working in the sidebar. I’ll include details of how to achieve that at the same time as the template editing.
- I actually only set the site up to demo this topic but I’ll leave it there and use it for further topics [↩]