On: 2006/01/19 Viewed: 24763 times

For almost every PHP script I publish, some readers have to do it : ask for help because they get a PHP warning telling that "headers already sent blablabla". So, for almost every PHP script I publish, I have to explain again and again the same thing about trailing blank spaces. Boring for me, frustrating for them.

Did you say something about "headers already sent" ?

The last time it happened, I said to myself : "Gee. I really have to make something that automatically handles things whenever someone asks about those darn headers".

So, I replied to myself : "hey, looks like a fun plugin idea !"

A few minutes later (as if) here is another plugin for Wordpress : the FAQ Auto Responder

FAQ Auto Responder : the concept

You define an array of frequently asked questions and their answers :
'question' => 'answer'

For instance, about the headers warning, this would be something like :

PHP:
  1. 'headers already sent' => 'please remove blank lines'

FAQs are defined as case insensitive regular expression patterns. For instance, if you keep having comments on your blog asking what is your name, you can add the following pair of FAQ and answer :

PHP:
  1. "what(\ is|(\\\')?s) your name" => 'Duh ! My name is Ozh !'

As you can see, things need to be rather escaped to work properly, but the above example will take care of the following strings :
what is your name
what's your name
whats your name

FAQ Auto Responder : the demo

The plugin is activated right here and right now, so to give a try, you could add a comment like "omg please help i have an error with headers already sent !!!" (or anything containing "headers already sent")

You can also give the name question a shot. And why not, wonder something silly like "headers already sent by me, but what is your name again ?" to trigger several FAQs.

Attention testers: feel free to test, but PLEASE test using your brain. The plugin is configured here to react on "headers already sent". Posting something with "header" instead of "headers", "send" instead of "sent", etc..., obviously won't work. PLEASE also refrain from actually submitting your test comment once it's been catched by the Auto Responder. I will mark as spam those who don't follow this.

FAQ Auto Responder : the file

Download the plugin :
ozh-faq-auto-responder.zip
Extract and upload to your blog, preserving directory structure if any.
Note: download counter here and stats on wordpress.org may differ and reflect the number of downloads before this plugin was hosted on the plugin directory

FAQ Auto Responder : the features

You can configure a few things, since my religion forbids me to make plugins where you wouldn"t be able to make yourself at home. Edit the plugin and play with some variables.

$wp_ozh_faq["faq"]
This array defines the pairs of "faq" => "answer", as explained above.
If you feel uncomfortable with regular expression, just use plain text and add as many string as wanted.
This is obviously a mandatory editing.

Each time a comment contains what appears to be a FAQ, a page is displayed with some potential answer. Let"s make this page as user friendly and pretty as possible.

$wp_ozh_faq["header"]
This prints first. Put some HTML, CSS, title, style and explanations to tell your reader what the f*** is this page he was not expecting.
Optional token %%COMMENT%% will be replaced with user"s comment.

$wp_ozh_faq["reply"]
This part is echoed for each FAQ and their answer. Again, feel free to put here any HTML and text you want.
Mandatory tokens here are %%QUESTION%% and %%ANSWER%%, replaced with the FAQ pattern that was detected, and its answer.

$wp_ozh_faq["footer"]
Here comes the last chunk of HTML and stuff. Be sure to include %%FORM%%, which will be replaced with the hidden form data and submit button.

FAQ Auto Responder : the fine tuning

If you want to tweak how the page displays, send your browser directly on the plugin file (ie. http://yourblog.com/wp-content/plugins/ozh-faq-auto-responder/wp_ozh_faq.php). It will print a sample form so that modifying your CSS and text is easy and does not even need the plugin to be activated (like this)

If you want to test various regular expressions to check if comments are catched or go through, you can uncomment a block around line 171 to prevent comments to be submitted. It makes things easy with a lot of comment submissions without spamming your own blog.

Related posts

Metastuff

This page "FAQ Auto Responder for Wordpress Comments" was posted on 19/01/2006 at 2:50 pm
Watch this discussion : Comments RSS 2.0. You can trackback this post from your own site

26 Blablas

    Pages: « 1 [2] Show All

  1. 21
    Israel Meneses United States »
    wrote, on 13/Jan/08 at 2:08 am # :

    I want to ask how this FAQ works, thanks

  2. 22
    Dave United States »
    said, on 28/May/08 at 8:08 am # :

    I hope this will work. It is what I am looking for. Thanks

  3. 23
    Team Biff United States »
    thought, on 12/Aug/08 at 12:33 am # :

    Incredible idea and excellent plugin! Question: will this work on comment forms or is it exclusive just to the post/page comments?

    I want to set it up to filter a "Contact Me" custom form (that's where I get all of my questions), is that possible?

    Again, I love your how user-friendly your plugins are! Thanks!
    ~Biff.

  4. 24
    Ozh France »
    thought, on 12/Aug/08 at 12:42 am # :

    Team Biff » This will work anywhere WordPress accepts comments. Your contact page is most likely this.

  5. 25
    buyungupik Indonesia »
    wrote, on 02/Oct/08 at 8:36 am # :

    oh dude , i just realize than on my screen pop out dialogue box like headers already sent , just want try the demo here :D

  6. 26
    FAQ Auto Responder for Wordpress Comment... Germany »
    pingback on 02/Oct/08 at 9:13 am # :

    [...] FAQ Auto Responder for Wordpress Comments von Ozh sendet automatiscxh eine Art FAQ zu Fragen die über die Kommentarfunktion gestellt werden. Der Admin kann Standardfragen definieren, tauchen diese Fragen in einem Kommentar auf, sendet das Plugin automatisch eine Antwort. Bookmarks setzen: Diese Icons verlinken auf Bookmark Dienste bei denen Nutzer neue Inhalte finden und mit anderen teilen können. [...]

Pages: « 1 [2] Show All

Leave a Reply

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.

Close
E-mail It