Is there any hook to validate google recaptcha dislayed in wp-signup page [in Wordpress Multisite]

First time working on a directory base WordPress multi-site. I need to add google ReCaptcha in the wp-signup.php page.I

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 The 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
  • This works! Thank You. Note: if you please copy your comment and paste as an answer, I will choose it as the answer. – Shah Alom Commented Oct 1, 2019 at 19:11
Add a comment  | 

1 Answer 1

Reset to default 0

The 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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信