• Resolved josephonduty

    (@josephonduty)


    I don’t want to update the option on the settings page. But I want to set “reCaptcha Version 2” as the default option with the plugin install.

    Please let me know.

    Thanks,
    Joseph

Viewing 1 replies (of 1 total)
  • Plugin Author IQComputing

    (@iqcomputing)

    We understand this is an extra step that may seem unnecessary. The reason for this extra step was to allow people with ReCaptcha version 3 already activated to downgrade if they choose without effecting the front-end of their website. By defaulting to ReCaptcha version 2 upon install would invalidate any front-end Contact Form 7 forms that run version 3 keys. It’s a step we feel is necessary to accommodate users installing this plugin in different situations than fresh installs.

    If you’re referring to Multisite installs, we are currently testing a version of the plugin to allow the Network Admins to apply changes to all Network sites which we hope to push in the near future.

    – – – – –

    Finally, if you are looking for a developmental example of how you could do this, below is a code snippet which will update the option whenever the admin panel is loaded whether or not the plugin is installed. Since this is a code-based solution we feel the need to stress that you should apply the below code at your own risk as applied incorrectly could break your website. It’s not an advisable solution for non-developers.

    /**
     * Set default options
     * 
     * @return void
     */
    function prefix_set_default_options() {
    	
    	// Contact Form 7 is not installed or not activated.
    	if( class_exists( 'WPCF7' ) ) {
    		
    		// If the option exists and is set, return early
    		if( false !== WPCF7::get_option( 'iqfix_recaptcha', false ) ) {
    			return;
    		}
    		
    		WPCF7::update_option( 'iqfix_recaptcha', '2' );		// Set ReCaptcha to user v2
    		
    	// Attempt to set options for when Contact Form 7 is installed.
    	} else {
    		
    		/**
    		 * @see Code written by Takayuki Miyoshi
    		 * @see Contact Form 7 v5.1.1 settings.php LN80
    		 */
    		$option = get_option( 'wpcf7' );										// Get Contact Form 7 Settings
    		$option = ( false === $option ) ? array() : (array) $option;			// If they do not exist, create an array
    		
    		// If the option exists and is set, return early
    		if( array_key_exists( 'iqfix_recaptcha', $option ) ) {
    			return;
    		}
    		
    		$option = array_merge( $option, array( 'iqfix_recaptcha' => '2' ) );	// Merge the two arrays
    		update_option( 'wpcf7', $option );										// Update Option
    		
    	}
    	
    }
    add_action( 'after_setup_theme', 'prefix_set_default_options', 20 );
Viewing 1 replies (of 1 total)
  • The topic ‘Change default option from “Default Usage” to “reCaptcha Version 2”’ is closed to new replies.