On: 2006/01/19 Viewed: 55290 times
Shorter URL for this page: http://ozh.in/lb

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 :

  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 :

  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.

Shorter URL

Want to share or tweet this page? Please use this short URL: http://ozh.in/lb

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.

43 Blablas

  1. 1
    Tinus Netherlands »
    replied, on 23/Feb/06 at 3:22 pm # :

    I'd like to ask something about headers allready sent..

  2. 2
    Ozh France »
    thought, on 23/Feb/06 at 3:37 pm # :

    (In case you're wondering why it didn't work: you misspelled "allready" with 2 L's)

  3. 3
    Will United States »
    said, on 19/Apr/06 at 6:17 am # :

    lol Learn to copy and paste. ;)

    um perhaps not show the extra trigger ;)

  4. 4
    pepe Spain »
    wrote, on 12/Jul/06 at 10:15 pm # :

    What is this plugin about?

  5. 5
    dx Argentina »
    wrote, on 25/Jan/07 at 1:22 am # :

    how do i activate the plugin?

    (ok, that was a teh ssssttt)

  6. 6
    dx Argentina »
    wrote, on 25/Jan/07 at 1:22 am # :

    failed test :(

  7. 7
    Luggruff Norway »
    replied, on 15/May/07 at 3:51 pm # :

    your headers has already been sent ! (and that plugin doesn't seem to be that bulletproof.. just see how your answer was about the word always and not the headers!)

  8. 8
    Ozh France »
    thought, on 15/May/07 at 8:53 pm # :

    Luggruff » yeah right.

  9. 9
    Gary United States »
    thought, on 06/Oct/07 at 1:52 am # :

    I was wondering if your headers had already been sent and will then know what to do?

  10. 10
    WP插件:FAQ Auto Responder-é—... United States »
    pingback on 09/Oct/07 at 1:14 pm # :

    [...] WP官方下载页面 | 插件作者下载页面 [...]

  11. 11
    dicki Netherlands »
    said, on 17/Oct/07 at 8:57 pm # :

    headers already send?

  12. 12
    Ozh France »
    wrote, on 18/Oct/07 at 1:51 am # :

    dicki » Welcome into the group of people who just cant read. Obviously and by no means "headers already send" cannot be matched by "headers already sent" (not adding it doesnt make any sense, of course)

  13. 13
    WordPress Plugins Spotlight for 10.1.07 ... United States »
    pingback on 02/Nov/07 at 3:51 am # :

    [...] if you run a blog where users frequently ask the same questions over and over again. Brills! Read About It | Download [...]

  14. 14
    WordPress Plugin - Massor av bra WordPre... Sweden »
    pingback on 06/Nov/07 at 1:56 am # :

    [...] FAQ Auto Responder Har du en blogg där dina besökare ställer samma frågor hela tiden, då kanske detta är något som kan hjälpa dig att spara tid. [...]

  15. 15
    J.P. Argentina »
    commented, on 12/Nov/07 at 3:12 am # :

    Where are the headers already sent! And what is your name doing in the footer?

  16. 16
    J.P. Argentina »
    wrote, on 12/Nov/07 at 3:12 am # :

    Sorry for that :)

    Mate, this is awesome.

  17. 17
    adan United States »
    thought, on 21/Nov/07 at 6:58 pm # :

    what is my name? what is your name? what are our names?

    Okay, now this is a serious question: What plugin are you using for that \

  18. 18
    adan United States »
    commented, on 21/Nov/07 at 7:01 pm # :

    Hmm. Your plugin appears to have cut off my question. I was asking what plugin you use for the posting code feature.

  19. 19
    Nestor Spain »
    replied, on 24/Nov/07 at 4:11 pm # :

    Hah, that's a good one. I better add plenty of misspellings to the regular expressions though, because the blog I was thinking of using it on has commenters that spell really bad :)

  20. 20
    pigs United States »
    said, on 12/Jan/08 at 8:15 am # :

    what is your name?

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

    I want to ask how this FAQ works, thanks

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

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

  23. 23
    Team Biff United States »
    replied, 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.

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

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

  25. 25
    buyungupik Indonesia »
    thought, 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

  26. 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. [...]

  27. 27
    Rosie United Kingdom »
    wrote, on 09/Nov/08 at 5:54 pm # :

    how do I install this

  28. 28
    Ozh’ FAQ Auto Responder United States »
    pingback on 30/Jan/09 at 6:24 pm # :

    [...] documentation and tips, please refer to the official plugin page for FAQ Auto Responder Download Plugin! Version 1.0.1 Last Updated: August 11, 2008 [...]

  29. 29
    WordPress Plugin List 6 « Graphic ... United States »
    pingback on 05/Mar/09 at 8:13 pm # :

    [...] For documentation and tips, please refer to the official plugin page for FAQ Auto Responder [...]

  30. 30
    jake United States »
    wrote, on 20/Mar/09 at 11:19 pm # :

    omg please help i have an error with headers already sent !!!

  31. 31
    blameitonkarma United States »
    said, on 07/Sep/09 at 2:36 am # :

    I hope this is what I'm looking for. I guess we'll see.

  32. 32
    Steven South Africa »
    commented, on 03/Jan/10 at 6:08 pm # :

    Which code plugin do you use?

  33. 33
    Anna Spain »
    wrote, on 24/Dec/10 at 2:17 am # :

    how come headers are already sent?

  34. 34
    Anna Spain »
    wrote, on 24/Dec/10 at 2:18 am # :

    let's try this again with a space after "sent". how come headers are already sent ?

  35. 35
    Ozh France »
    said, on 24/Dec/10 at 9:03 am # :

    Anna » You fail at reading. The plugin here is configured to catch "headers already sent", as in the common PHP error. Not "headers are already sent". But thanks for trying.

  36. 36
    Anil India »
    replied, on 03/Apr/11 at 11:55 am # :

    Looks great ! But I wonder if it works on Multi -Site installation of 3.1 version. I w'l give a try

    Thanks !

  37. 37
    Daan Netherlands »
    thought, on 23/May/11 at 7:06 pm # :

    headers ?

  38. 38
    pesi Italy »
    commented, on 01/Oct/12 at 5:47 pm # :

    Hi, thank you for this great plugin.
    i have a question: I'm from italy and the plugin don't catch words like "verrà" can you please explain me how can i modify the php code for work in my language? Thank you and sorry for my poor english.

  39. 39
    Ozh »
    replied, on 01/Oct/12 at 9:21 pm # :

    pesi » try various HTML encoded forms, replacing the "à" with "à" or "à". If that still doesn't work: sorry, don't know.

  40. 40
    Ozh »
    replied, on 01/Oct/12 at 9:22 pm # :

    pesi: of course it didnt show up correctly. I meant: replace "à" with "& agrave;" (no space) or "& #224;" (no space)

  41. 41
    pesi Italy »
    said, on 01/Oct/12 at 10:04 pm # :

    Hi, thank you for the fast reply, I have already added a faq formatted in this way:

    'cioè' => 'test',

    and then added this line of code under line 107 of "wp_ozh_faq.php":

    $comment = str_replace ("è", "è", $comment);

    but it don't work :-(
    any idea? Bye

  42. 42
    pesi Italy »
    wrote, on 01/Oct/12 at 10:07 pm # :

    Ops, i did the same error :-))

    'cio& #232;' => 'test',
    $comment = str_replace ("è", "& #232;", $comment);

    sorry

  43. 43
    Ozh »
    commented, on 01/Oct/12 at 10:37 pm # :

    pesi » Don't try anything complicated, don't alter the plugin. Just act as if commenters were going to type "cerr& agrave" or "cerr& #123; instead of "cerrà". Then, again, if that doesn't work: I don't know :)

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.