• Resolved imran4191

    (@imran4191)


    I am using wpforms lite for creating forms. I added recaptcha in that form. Now i want this recaptcha only shows or works for not logged in user. Logged in users should able to submit the form without recaptcha. How can i achieve that? Thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @imran4191,

    Thanks for reaching out!

    To disable reCAPTCHA for automated testing, you can use the code snippet shared in our guide here.

    /**
    * Disable CAPTCHA for all logged-in users
    *
    * @link https://wpforms.com/developers/how-to-disable-recaptcha-for-automated-testing/
    */

    // Skip CAPTCHA for logged in users only.
    add_action( 'plugins_loaded', static function() {

    // Check if the current visitor is a logged in user.
    if ( is_user_logged_in() ) {

    add_filter( 'wpforms_process_bypass_captcha', '__return_true' );
    add_filter( 'wpforms_frontend_recaptcha_disable', '__return_true' );
    remove_action( 'wpforms_frontend_output', [ wpforms()->get( 'frontend' ), 'recaptcha' ], 20 );
    }

    }, 11 );

    In case you need it, here’s a tutorial with the most common ways to add custom code, including this type of snippet. For a beginner-friendly option, I recommend using the WPCode plugin.

    I hope this helps! Please feel welcome to let me know if you have any further questions.

    Thread Starter imran4191

    (@imran4191)

    Hi
    I used the code you provided in function.php but it didn’t work for me.

    /**

    // Skip CAPTCHA for logged in users only.
    add_action( ‘plugins_loaded’, static function() {

    // Check if the current visitor is a logged in user.
    if ( is_user_logged_in() ) {
    
        add_filter( 'wpforms_process_bypass_captcha', '__return_true' );
        add_filter( 'wpforms_frontend_recaptcha_disable', '__return_true' );
        remove_action( 'wpforms_frontend_output', [ wpforms()->get( 'frontend' ), 'recaptcha' ], 20 );
    }

    }, 11 );

    Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @imran4191,

    Thanks for letting me know!

    However, the code snippet from our guide here worked for me. For your reference, I’ve created this screencast.

    When you have a moment, could you please try again using the WPCode plugin, as I demonstrated in the screencast? The code snippet should work for you.

    Thanks! And please let me know if you have any further questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.