WordPress.org

Ready to get started?Download WordPress

Forums

WP-reCAPTCHA
Doesn't save keys for WordPress 3..05 (18 posts)

  1. huyz
    Member
    Posted 2 years ago #

    This plugin doesn't seem to have been updated for 3.0.5, as it doesn't save entered keys.

  2. huyz
    Member
    Posted 2 years ago #

    Right now, it looks like version 3.1.3 of the plugin cannot work for a multisite setup using WordPress 3.x.

    To understand why, the first thing to know is that there are two types of settings: network-wide and per-blog.

    The plugin's multisite-handling code makes two mistakes:

    • It assumes that there's a simple API for setting the network-wide settings just as easily as it's done for the per-blog options. That API doesn't yet exist. See http://wordpress.stackexchange.com/questions/18314/global-settings-page-for-multisite-plugin. The current code writes to the per-blog settings and then tries to read the network-wide settings. So now you know why saved keys (and other settings) will not be read back.
    • It tries to set/read all settings, whether network-wide or per-blog, using a single method (which as I described in the previous bullet point is broken). The plugin should use two separate methods depending on which settings page the admin is using: (a) read/write network-wide settings manually and (b) read/write per-bog settings using Settings API.

    In the meantime, here's a workaround:

    Change wp-plugin.php:

    static function retrieve_options($options_name) {
                    return get_option($options_name);
            }
    
    static function remove_options($options_name) {
                    return delete_option($options_name);
            }
    static function add_options($options_name, $options) {
                    return add_option($options_name, $options);
            }

    While you're at it, you might as well disable the "Super/Network Admin" settings page by changing recaptcha.php:

    function add_settings_page() {
                // add the options page
    /*
                if ($this->environment == Environment::WordPressMU && $this->is_authority())
                    add_submenu_page('wpmu-admin.php', 'WP-reCAPTCHA', 'WP-reCAPTCHA', 'manage_options', __FILE__, array(&$this, 'show_settings_page'));
    
                if ($this->environment == Environment::WordPressMS && $this->is_authority())
                    add_submenu_page('ms-admin.php', 'WP-reCAPTCHA', 'WP-reCAPTCHA', 'manage_options', __FILE__, array(&$this, 'show_settings_page'));
    */

    This will allow you to have separate per-blog wp-recaptcha settings. But it will not allow you to have network-wide settings.

  3. alittlebitofnothing
    Member
    Posted 2 years ago #

    That seems to work great, thanks a lot!

  4. ddarby14
    Member
    Posted 2 years ago #

    @huyz - thanks a ton, great plugin fix and great explanation.

    I assumed wp-plugin.php was a WP file so I was hesitant until I realized *both* of these file edits are in the actual plugin. Now all is peaceful again.

    Thx again

  5. robpoe
    Member
    Posted 2 years ago #

    While it seems like it makes it work, I can enter anything (or nothing) into the ReCaptcha entry field and it will send the form, and not fail (as it should).

    It also saves my keys/settings (and I select "Clean" for the form -- and it shows me the "Red" one).

  6. huyz
    Member
    Posted 2 years ago #

    @robpoe
    It saves or doesn't save your settings?
    What is "it"? The plugin as released, or the plugin with my patches?

  7. robpoe
    Member
    Posted 2 years ago #

    Aha, I found the issue. It wasn't with your patches at all, it was with the contact-form-7-recaptcha-extension .. I had to remove a bunch of stuff from it (basically took out all the multisite code checking in it, too - to force it to be NON multi site).

    I'm using the wp-recaptcha plugin in conjunction with the contact-form-7 to try to help cut down spam on the contact forms (who would want to viagra spam a police department is beyond me!)...

    Anyway, if you're wanting the fix, here it is:

    http://itofkc.net/WPASDPlugin.class.txt

    Drop that into your

    wp-content/plugins/contact-form-7-recaptcha-extension/includes/

    as

    WPASDPlugin.class.php

    (back up your old one first. This is for the version that lists itself as 0.0.8)

    By the way, thank you!!

  8. huyz
    Member
    Posted 2 years ago #

    For those who don't want to touch the code, you can download the entire patched plugin at:

    https://github.com/huyz/wp-recaptcha/archives/oo-refactor

  9. Andre Pietsch
    Member
    Posted 2 years ago #

    would it help if I use my plugin (contact form 7 recaptcha extension) to copy the site options of wp-recaptcha to the blog options? something like

    if (is_multisite()) {
    update_option(get_site_option(...)));
    }

    then you don't need to patch the whole thing by removing some code...

    I know it is maybe some kind of dirty, but if they update their plugin without fixing the bug you have to make a new fix...

  10. Andre Pietsch
    Member
    Posted 2 years ago #

    ah damn... that wouldn't work :(

  11. madivad
    Member
    Posted 2 years ago #

    from the second post with the new code, I just want to know, do we simply insert this code at the top of the said file? or do we replace the existing functions with these? or replace the whole file with just that code?

  12. Andre Pietsch
    Member
    Posted 2 years ago #

    Hi,

    after the hint I changed the code to match that solution. The current code only saves values blog local. The parts for the MS or MU are deactivated.

    But you can also replace the function or the file using the 7th or 8th post.

    I'am working on a version that matches the needs of MU / MS more precisely.

    Kind regards

    Andre

  13. madivad
    Member
    Posted 2 years ago #

  14. Andre Pietsch
    Member
    Posted 2 years ago #

    No problem... You are more than welcome.

    As I said: I have adopted the code into the current version of the plugin. If you use the current version available you don't have to patch something.

    Report back if you still have problems. I will take care of it in the next version.

  15. madivad
    Member
    Posted 2 years ago #

    The current version of which plugin? I'm now a little confused. I'm talking about the reCAPTCHA plugin authored by BlaenkDenum. Are you involved with this project? I don't see how you could edit his code, which I only downloaded today and is the stated 3.1.3.

    But now in having a look at what you've done, you've just killed the better part of my whole day redesigning my current theme's contact form, because I wanted two different types of contact forms. Took me several hours to do, and now I just found your plugin which looks it would have done it perfectly! DOH!

    I now may just destroy my night and have a look at what you've done! LOL

  16. Andre Pietsch
    Member
    Posted 2 years ago #

    Hey... :D

    You are right, I am not involved with the WP-reCAPTCHA plugin.

    In this thread we discussed about an error handling options of WP MS/MU instances in connection with WP-reCAPTCHA. At the end we talked about a solution for the problem in my "Contact Form 7 reCAPTCHA Extension". I thought you were talking about that too. Sorry for the confusion.

    The solution he mentions in the second post is applicable to every plugin that uses his code. The solution in the 7th and 8th post is especially for the people who use my plugin. Don't mix them up.

    Ah... I don't know how to respond to the second part of your post. Is it good that I have made my plugin or bad? LOL

    Anyway I hope it helps. ;)

  17. madivad
    Member
    Posted 2 years ago #

    I actually downloaded and had a quick look at your plugin, it doesn't quite do what I was looking for. Obviously, for a contact form, it's often required that an email is sent to someone. But what I needed (and have been working on today), was working with the comments system to create a new type of page. Basically an old fashioned guestbook page. In this instance I needed the plugin to not emil me, but just insert the user data into the database and retrieve it on the guestbook page.

    I used the comments system to do this, and somewhere along the way I started confusing comments (which work as I needed them) with contact forms (which really do something entirely different).

    I have no use for your plugin at the moment, so it's remaining deactivated, however, not deleted. Because (basically) I'm sure I'll find a use for it ;-)

    Good work, I just wish I had a greater programming knowledge than I actually do so I could get into developing plugins more. But I need to spend LESS time on the computer, not MORE!!! LOL

  18. Bernhard Riedl
    Member
    Posted 2 years ago #

    @huyz: thanks for the patch. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic