Skip to content

Commit

Permalink
Add Captcha to login page
Browse files Browse the repository at this point in the history
Signed-off-by: Kipruto <[email protected]>
  • Loading branch information
kelvinkipruto committed Aug 26, 2024
1 parent 815ac01 commit b0d05d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion wp-content/themes/academyAfrica/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function child_theme_configurator_css()

// END ENQUEUE PARENT ACTION

define('ACADEMY_AFRICA_VERSION', '1.4.2');
define('ACADEMY_AFRICA_VERSION', '1.4.3');
const MINIMUM_ELEMENTOR_VERSION = '3.16.6';


Expand Down
21 changes: 20 additions & 1 deletion wp-content/themes/academyAfrica/template-parts/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,26 @@
<p id="login_error">
</p>
</div>
<?php wp_login_form(array('value_redirect_to' => $_GET['redirect_url'], 'redirect' => $_GET['redirect_url'])); ?>
<?php
// Capture the login form output
ob_start();
wp_login_form(array('value_redirect_to' => $_GET['redirect_url'], 'redirect' => $_GET['redirect_url']));
$form_output = ob_get_clean();

// Get the Google Captcha shortcode output
$captcha_output = do_shortcode('[bws_google_captcha]');

// Find the position of the submit button
$submit_button_pos = strpos($form_output, '<input type="submit"');

// Insert the captcha before the submit button
if ($submit_button_pos !== false) {
$form_output = substr_replace($form_output, $captcha_output, $submit_button_pos, 0);
}

// Echo the combined output
echo $form_output;
?>
<footer style="display: flex; justify-content: space-between;" class="modal-footers">
<div>
<span>New to academy.AFRICA? </span><a class="remember-me" href="/login?action=register" style="margin-left: 4px; font-size: 16px;">Register
Expand Down

0 comments on commit b0d05d8

Please sign in to comment.