Idea for a fix to the Add New Users Error: Fill out Recaptcha form (doesnt show)
-
When a normal (site NOT super) admin tries to add a user in WordPress Multisite, a message comes up stating that you need to fill out a recaptcha page. However no recaptcha shows, and why would you need to, when you are an admin and doing so in the administrative dashboard?
I found this discussion which explains how to determine the php page you are on. So looking in the recaptcha.php code, there is a section where the author intended to add a check, to see if you were on the Add New Users Page, and then skip validation. This never got added.
I have an idea, but as I am a bad coder, i am getting it wrong, and it causes the Add New User page to blank out…
So looking at recaptcha.php:
function validate_recaptcha_response_wpmu($result) { // must make a check here, otherwise the wp-admin/user-new.php script will keep trying to call // this function despite not having called do_action('signup_extra_fields'), so the recaptcha // field was never shown. this way it won't validate if it's called in the admin interface if (!$this->is_authority()) { // blogname in 2.6, blog_id prior to that // todo: why is this done? if (isset($_POST['blog_id']) || isset($_POST['blogname'])) return $result; // no text entered if (empty($_POST['recaptcha_response_field']) || $_POST['recaptcha_response_field'] == '') { $result['errors']->add('blank_captcha', $this->options['no_response_error']); return $result; } $response = recaptcha_check_answer($this->options['private_key'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
At this point I thought about placing code like this here, but obviously am a bad coder and can’t get this to work. Any ideas?
if basename (($_SERVER["PHP_SELF"]) = "user-new.php") { $response = is_valid; }
Now the code continues on to check whether the response was valid or not. Was hoping to hardcode it as valid, if the page filename was user-new.php…
// response is bad, add incorrect response error // todo: why echo the error here? wpmu specific? if (!$response->is_valid) if ($response->error == 'incorrect-captcha-sol') { $result['errors']->add('captcha_wrong', $this->options['incorrect_response_error']); echo '<div class="error">' . $this->options['incorrect_response_error'] . '</div>'; } return $result; } }
- The topic ‘Idea for a fix to the Add New Users Error: Fill out Recaptcha form (doesnt show)’ is closed to new replies.