The MU forums have moved to WordPress.org

Trying to Make WP-reCAPTCHA MU Compatible (42 posts)

  1. BlaenkDenum
    Member
    Posted 14 years ago #

    Hey guys, I'm the developer for the official reCAPTCHA WordPress Plugin and it works well in regular WordPress but I've been getting many requests to make it work on WPMU. Since I haven't been able to find much documentation (I also tried getting help on the wp-hackers mailing list) and because I don't really have a great understanding of WPMU, I'm having trouble doing this. I think I'm almost done making it compatible I just need someone to test it and tell me how it goes.

    This plugin allows one to put a reCAPTCHA on the registration page, the comments form, and/or hide emails from spammers using MailHide. I think the main difference when adapting to MU is changing the place where the plugin options are (Because people want it to be in the mu-plugins directory so that it's force activated) so that they appear under the site admin section or something, I believe I've done that. Also the main change I must do to the plugin is change the hooks I hook onto for the registration page. I've already done this as well, and I'm now using signup_extra_fields and wpmu_validate_user_signup. The former to display the reCAPTCHA and the latter to see if it's correct.

    The only last confusion I have is the mu-plugins directory. Am I allowed to put the entire wp-recaptcha folder in there? This folder includes the actual plugin wp-recaptcha.php as well as the PHP reCAPTCHA library recaptchalib.php, a stylesheet, and a few other things. Or am I supposed to put the plugin wp-recaptcha.php in mu-plugins and also a copy of the wp-recaptcha folder (Also including wp-recaptcha.php) in the wp-content/plugins folder? I would appreciate any clarification you could provide.

    Like I said, I'm nearly done (Or so I believe) making this MU compatible after having looked at the MU code and other MU plugins. If anyone would be so kind as to test the latest revision found at http://svn.wp-plugins.org/wp-recaptcha/trunk/ I would greatly appreciate it.

  2. honewatson
    Member
    Posted 14 years ago #

    The admin pages should go under the "Site Admin" area.

    The plugin should be stored in mu-plugins so that the plugin runs automatically across all blogs.

    The plugin will not run if all the files are located in wp-recaptcha folder. eg /mu-plugins/wp-recaptcha

    Instead you will need to have:

    /mu-plugins/wp-recaptcha.php
    /mu-plugins/wp-recaptcha/*

    Here is the code that implements the admin pages for the super cache plugin. It checks if the is_site_admin function exists which means its a mu installation, if it doesn't its a standard wordpress installation.

    function wp_cache_add_pages() {
    	if( function_exists( 'is_site_admin' ) ) {
    		if( is_site_admin() ) {
    			add_submenu_page('wpmu-admin.php', __('WP Super Cache'), __('WP Super Cache'), 'manage_options', __FILE__, 'wp_cache_manager');
    			add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', __FILE__, 'wp_cache_manager');
    		}
    	} else {
    		add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', __FILE__, 'wp_cache_manager');
    	}
    }
    add_action('admin_menu', 'wp_cache_add_pages');

    The add options function and the add submenu function include the name of the page to create, the function which handles the requests on the query uri, and the file that handles the requests.

    http://codex.wordpress.org/Adding_Administration_Menus

  3. BlaenkDenum
    Member
    Posted 14 years ago #

    I finally implemented MU compatibility.

    http://wordpress.org/extend/plugins/wp-recaptcha/ version 2.8.3

  4. honewatson
    Member
    Posted 14 years ago #

    Thanks, since it works so well for facebook, I'm going to test it out.

  5. fouad.fakhr
    Member
    Posted 14 years ago #

    it works so fine on my test site
    but i think there's something with the signup and login boxes

    in the signup it's shown above the form but the source code should goes below it

    and it makes the login form wider , although it's not shown on the login form

    thanks jorge

  6. demonicume
    Member
    Posted 14 years ago #

    what about subdirectories? i'm on a subdir install and my blogs all get the message that they need a key to use the plugin.

  7. fouad.fakhr
    Member
    Posted 14 years ago #

    demonicume
    i added the pub and priv keys to the code , just search for them and put your values in wp-recaptcha.php lines 225 and 488 , both pubkey and privkey to be filled
    i wish if this plugin won't appear to the user at all , i used to face nearly 10 sblogs every day on a site that's not open or even advertised , today i got zero blogs so i think it may "reduce" alot of spam
    but the problems are :
    1- login css is making the login box on wp-login.php wider
    2- the signup recaptcha appears on the top and left to the input fields and this makes the recaptcha not easily to be recognized as part of registeration process , i saw the same problem on your site demonicume
    3- when it's left blank on registeration form there's no error message so the user might think it's something else but captcha

    that's all i found till now and hope those problems to be fixed. anyway i'll use it on my wpmu installation soon

  8. BlaenkDenum
    Member
    Posted 14 years ago #

    Hey guys I just realized that problem and I know how to fix it. My guess is that I will have to make reCAPTCHA on WordPress MU forced only. The reason it's asking for the keys is because I use add_option to store some recaptcha options but the options are only blog specific, so even though the admin sets the option it only applies to their blog and not everyone else's

    As for the plugin appearing on everyone else's page, I just realized that and I know how to fix it so don't worry.

    As for the form appearing above the contact form, I've said this many times over, read the instructions. You're supposed to have this structure: /mu-plugins/wp-recaptcha.php and then the wp-recaptcha folder (minus wp-recaptcha.php at /mu-plugins/wp-recaptcha/. You then have to edit wp-recaptcha.php in line 20 (read the comments above it), basically set it so that $wpmu is equal to 1 instead of 0.

  9. fouad.fakhr
    Member
    Posted 14 years ago #

    i use it on my site now and i followed - actually i read every single comment in the code and readme file - and it showed the captcha box above the registration form not in the place and no error code for it when it comes to empty entry
    that's all i faced for now

    thanks jorge

  10. demonicume
    Member
    Posted 14 years ago #

    great response. i'll make the changes soon.

  11. BlaenkDenum
    Member
    Posted 14 years ago #

    Okay, 2.8.4 is fully functional it fixes the problem fouad.fakhr had above having to do with the empty entry or whatever.

    Get 2.8.4 either from http://wpmudevorg.wordpress.com/project/WP-reCAPTCHA or from http://wordpress.org/extend/plugins/wp-recaptcha/ .

    @fouad.fakhr: DON'T hard code the codes anymore, I fixed it so that it doesn't do that. I've fixed everything you guys have told me about I believe, test it and you will see. Make sure you read the instructions from whichever page you go to. Basically if you want it to be forced activated/site wide then you put wp-recaptcha folder in mu-plugins/ and you move the wp-recaptcha.php file out of the wp-recaptcha folder and into mu-plugins/. If you want it to be optionally activated by your users, then you simply install it as if you were installing for wordpress (wp-content/plugins).

    That should fix all of the problems. If you still have any problems or questions please let me know.

  12. fouad.fakhr
    Member
    Posted 14 years ago #

    the new version is working so fine now , and it doesn't show for logged in users
    but i have a question cuz you in wp-recaptcha.php mentioned that in line 14 : // WordPress MU settings - DON'T EDIT
    so does this mean we don't need to choose a variable for $wpmu ?

    thanks blaenk

  13. BlaenkDenum
    Member
    Posted 14 years ago #

    Yeah, I said in the email and in readme.txt (Which you should be reading) that you no longer have to edit that.

    Also, does it show above the form or below the form?

  14. BlaenkDenum
    Member
    Posted 14 years ago #

    Get version 2.8.5, it has an XHTML validation fix, if you care at all for validation that is.

  15. fouad.fakhr
    Member
    Posted 14 years ago #

    some of the wordpress themes shows the box in a funny way , but not the majority of them so i simply disabled those themes till it gets fixed
    i'll get the new version now , thanks BlaenkDenum

  16. BlaenkDenum
    Member
    Posted 14 years ago #

    Till it gets fixed? I can't really fix anything if you're not any more specific :/ can you take a screenshot? or at least be a bit more descriptive? Chances are it's the fault of the themes though.

  17. fouad.fakhr
    Member
    Posted 14 years ago #

    i meant to fix the theme itself :-D , it's something with it cuz it only appears with ff not ie , so i'll try to fix those themes :-)
    you did a wonderful job BlaenkDenum , sorry for my terrible english that made you think it's something with you plugin ,
    i tried other captchas on a test site and i got nearly 20 sblogs signup per day , but after i added wp-recaptcha plugin to a working site all i got is 2 sblogs and both are human signups - which isn't recaptcha problem - also the test site didn't get any sblog since i added your plugin

  18. BlaenkDenum
    Member
    Posted 14 years ago #

    fouad.fakhr: Thank you for helping me perfect the plugin! I assume everything is working great now then? Thanks again, hope you have less spam from now on! :) And don't worry, I understood your English very well it's just that sometimes I understood things differently due to lack of information, but it definitely wasn't your English. Good luck in the future with your blog.

  19. JuanManuel
    Member
    Posted 14 years ago #

    Hi, Thanks for the plugin. Still when I use it with signups I get Splogs trough the registration.

  20. bschwarting
    Member
    Posted 14 years ago #

    BlaenkDenum,

    The login form is still wider when i implement it. Do you think this is a theme issue or plugin issue?

    One other thing, I love the "clean" option, but it doesn't say "Type the two words". I know it seems petty, but some users aren't computer savvy and they would be totally lost.

    I added this to make the CAPTCHA error stand out (line 209 of wp-recaptcha.php):

    if (!$response->is_valid)
    if ($response->error == 'incorrect-captcha-sol') {
    $result['errors']->add('captcha_wrong', 'That reCAPTCHA was incorrect.');
    echo "<div class=\"error\"><font size=5 color=yellow><table bgcolor=#076EBC border=2 cellpadding=5 cellspacing=5><tr><td>Incorrect CAPTCHA, please try again!</td></tr></table></font></div>";
    }

    Thanks for all your hard work!

  21. demonicume
    Member
    Posted 14 years ago #

    i'm seeing the same thing as JuanManuel. It hasn't slowed the tide of splogs. it's weird because re-captcha is damn hard... even when you listen to the audio.

  22. lunabyte
    Member
    Posted 14 years ago #

    A captcha may stop (most) bots, but it won't ever stop a human registration.

  23. tdjcbe
    Member
    Posted 14 years ago #

    it won't ever stop a human registration

    Trust me, yes it will. If I can't read it, then I can't register a site. There's a lot of broken and/or hard to read captchas out there on the net.

  24. lunabyte
    Member
    Posted 14 years ago #

    Give me a break. Your distaste for captchas is irrelevant to the discussion.

    Let me rephrase my comment, to make it more tasteful to your needs:

    While a captcha may stop (most) bots, it typically won't stop a human who actually visits the page and registers.

    This of course assumes that the captcha isn't broken, and the visitor isn't blind or hard of sight, and can read the characters' language.

    However, since it also had an audible option, users hard of sight should be able to solve it most of the time.

    Then again, if they are deaf as well as blind, then they're most likely SOL.

    For those who are on the lower end of the genepool in terms of comprehension levels, then it may be something beyond the scope of their abilities.

    // end politically correct answer.

  25. bschwarting
    Member
    Posted 14 years ago #

    anyone know how to fix the larger than normal login box? nothing in the CSS looks obvious to fix.

  26. bschwarting
    Member
    Posted 14 years ago #

    anyone seen a fix for this?

  27. BlaenkDenum
    Member
    Posted 14 years ago #

    bschwarting: What theme are you using, some are wider than others, like clean is. I have no control over this, I don't work on/for reCAPTCHA, I simply write the official WordPress PLUGIN for it which INTERFACES with reCAPTCHA. So, I'm sorry but there's only so much I can do.

    The only reason I re-visited this thread was because I saw it in my blog stats, but otherwise I probably wouldn't have heard you guys. If you don't mind posting on the reCAPTCHA page then I will see your comments there for sure.

    If you have any other questions/problems please let me know.

  28. wehican
    Member
    Posted 14 years ago #

    Is there a reCAPTCHA for BBPress?

    Integrating WPMU with BBPress allows for a back door without some Captcha, doesn't it?

  29. BlaenkDenum
    Member
    Posted 14 years ago #

    Perhaps, I've no idea how BBPress works. To block that backdoor one would simply have to turn off registration through BBPress, which I think should be a feature/ability of BBPress but like I said, I have no experience with it. I might look into creating a plugin for it if there's enough demand.

  30. Bike
    Member
    Posted 14 years ago #

    I put it in mu-plugins and it works great, even on my renamed registration page.
    However, any user (on any subblog) can change the settings, read the keys and switch the captcha off.

    Said otherwise: if blog1 turns the captcha on, it is turned on sitewide. When blig2 doesn't like it, then he can turn it off again sitewide etc.

    Am I missing something or are there no per user/blog options saved?

    Cheers, Bike

    ps: of course I still want to give the user the choice of enebaling th re-captcha and to select the language. But they can use the genral keys (do not have to see them) and should not be able to switch registration captcha off

About this Topic

  • Started 14 years ago by BlaenkDenum
  • Latest reply from agreda