First time working on a directory base WordPress multi-site. I need to add google ReCaptcha in the wp-signup.php
page.
I just look at the wp-signup.php
file and found do_action( 'signup_extra_fields', $errors );
in the show_user_form function to display a google ReCaptcha in the wp-signup.php
page. Here is the code how I added the google ReCaptcha box in the registration form ...
function mcqacnet_example_callback( $errors ) {
printf( '<div class="g-recaptcha" data-sitekey="%s"></div>', 'my-secret-key' );
}
add_action( 'signup_extra_fields', 'mcqacnet_example_callback', 99);
function mcqacnet_captcha_js_in_footer() {
echo '<script src=".js" async defer></script>';
}
add_action( 'wp_print_footer_scripts', 'mcqacnet_captcha_js_in_footer' );
Now its time to validate the captcha when a user submits registration form. I looked at the wpmu_signup_user function but no hook define to use.
Please let me know if you have any idea to verify reCaptcha before registration.
Thank you for your time.
First time working on a directory base WordPress multi-site. I need to add google ReCaptcha in the wp-signup.php
page.
I just look at the wp-signup.php
file and found do_action( 'signup_extra_fields', $errors );
in the show_user_form function to display a google ReCaptcha in the wp-signup.php
page. Here is the code how I added the google ReCaptcha box in the registration form ...
function mcqacnet_example_callback( $errors ) {
printf( '<div class="g-recaptcha" data-sitekey="%s"></div>', 'my-secret-key' );
}
add_action( 'signup_extra_fields', 'mcqacnet_example_callback', 99);
function mcqacnet_captcha_js_in_footer() {
echo '<script src="https://www.google/recaptcha/api.js" async defer></script>';
}
add_action( 'wp_print_footer_scripts', 'mcqacnet_captcha_js_in_footer' );
Now its time to validate the captcha when a user submits registration form. I looked at the wpmu_signup_user function but no hook define to use.
Please let me know if you have any idea to verify reCaptcha before registration.
Thank you for your time.
Share Improve this question asked Sep 30, 2019 at 21:12 Shah AlomShah Alom 4981 gold badge5 silver badges14 bronze badges 2 |1 Answer
Reset to default 0The wpmu_validate_user_signup
hook might help. Though you'd have to be careful to only apply the reCAPTCHA validation when necessary. For instance, it shouldn't be checked during a REST API request for creating a user.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745108023a4611674.html
wpmu_validate_user_signup
hook might help. Though you'd have to be careful to only apply the reCAPTCHA validation when necessary. For instance, it shouldn't be checked during a REST API request for creating a user. – Timothy Jacobs Commented Oct 1, 2019 at 1:26