Support » Plugins » [Plugin: Simple Facebook Connect] Breaks my plugins that use CAPTCHA – I have fix

  • Resolved Mike Challis


    Two SFC plugins are causing a conflict with two of my plugins.

    My plugins:
    Fast and Secure Contact Form

    SI CAPTCHA Anti-Spam

    If SFC – Like Button or SFC – Share Button is activated then my CAPTCHA image is being selected for a LIKE or SHARE image. This causes a new session that breaks the captcha cookie rendering the CAPTCHA unusable. Also the user will see an error when posting the form:
    “Could not read CAPTCHA cookie.”

    Easy Fix:
    Edit the code in sfc-like.php and sfc-share.php to prevent the secureimage-captcha image from ever being selected.

    In each file sfc-like.php and sfc-share.php
    if ( isset($img['src']) ) {

    Replace with:
    if ( isset($img['src']) && !preg_match('/captcha-secureimage/', $img['src'])) {

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    That’s not a bug. If you’re inserting an image directly into post content, then it’s going to get found by other plugins and correctly assumed to actually be part of the post content.

    One workaround would be to mark your image as a smiley. Anything with a class of wp-smiley gets ignored.

    However, the better fix would be to not insert the image into post content. Insert it somewhere else, or provide the user with a function to call from the theme to insert the image.

    For the “anti-spam” plugin, you should probably use the standard action hook of “comment_form” to put it by the comment form block, perhaps.

    I will not be putting special code in SFC to deal with other plugins that are doing weird things. If I did that, then I’d be just endlessly adding code to the thing. However, I will add a filter which will let you add a class to check for, like it does for the wp-smiley class. So that you can add your own class name then use the filter to add it to the exclusions list. That way, other plugins can add their own classes and I won’t have to be continually putting in special cases.

    Done. Code is in trunk, will be in version 0.22. I’ve not tested it, so try it out, let me know. Here’s how you can use it:

    1. Put a unique class on your images.

    function myfilter($classes) {
    $classes[] = 'my-unique-class';
    return $classes;

    That should do the trick.

    It does not work

    Fatal error: Call to undefined function straipos() in wp-content/plugins/simple-facebook-connect/sfc-like.php on line 188

    I am assuming straipos was a typo?
    supposed to be strpos?

    This line just does not work even if I put my class in it for testing(probably because an array is not a string):

    (isset($img['class']) && false === strpos($img['class'], apply_filters('sfc_img_exclude',array('ctf-captcha'))))

    This works, it matches my class, but it bypassed the filter idea
    (isset($img['class']) && false === strpos($img['class'], 'ctf-captcha' ))

    any ideas?

    Got it working…
    There was a missing return $classes; in the function

    In your files, I had to do this:

    if ( isset($img['src']) ) {
    				if (!isset($img['class']) ||
                        (isset($img['class']) && !in_array($img['class'], apply_filters('sfc_img_exclude',array('wp-smiley'))))
    					) { // ignore smilies

    In my file I had to do this (mine is a class)

    function ctf_sfc_filter($classes) {
    $classes[] = 'ctf-captcha';
    return $classes;


    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    No, straipos was not a typo. It’s a new function defined at the bottom of the file.

    Your changes are unnecessary, and in fact won’t work. Images don’t necessarily have only one “class”.

    OK that works, thanks.

    PS something else to tell you…
    With debugging on I get this error

    Notice: Undefined index: HTTPS in /wp-content/plugins/simple-facebook-connect/sfc-base.php on line 9

    I would change:
    if ($_SERVER['HTTPS'] == 'on')

    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    There’s a few minor things like that. I’ve been meaning to fix them, but I’m in the middle of changing jobs right now, and just don’t have the time. Maybe in a week or so.

    I am getting more complaints.

    SFC Like and SCF Share are both not compatible with Fast Secure Contact Form, they cause the error
    “Could not read CAPTCHA token file. CAPTCHA token file is missing.”

    It looks to me that it is caused by the SCF plugins trying to scan the page content prior to WordPress showing it. This interferes with proper posting of the form. In my opinion, the author of SFC should make a page exclusion feature so pages can be excluded from the SFC Like and SCF Share features.

    One time we collaborated on a fix for the captcha image showing up in the meta tags. This problem is a separate issue I cannot figure out how to resolve. For now I will have to tell people of the incompatibility unless you can figure out the cause and fix it.

    I too am having theses issues. I would really love to be able to disable the like plugin on pages.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Simple Facebook Connect] Breaks my plugins that use CAPTCHA – I have fix’ is closed to new replies.