Title: Multisite Master API Keys
Last modified: August 21, 2016

---

# Multisite Master API Keys

 *  [anielsen](https://wordpress.org/support/users/anielsen/)
 * (@anielsen)
 * [12 years ago](https://wordpress.org/support/topic/multisite-master-api-keys/)
 * I am using this plugin on a Multisite install of WordPress and was wondering 
   if there was a way to store my API keys globally so that every site that activates
   this plugin has the keys pre-populated? Similar to how Gravity Forms does it:
   [http://www.gravityhelp.com/documentation/page/Advanced_Configuration_Options](http://www.gravityhelp.com/documentation/page/Advanced_Configuration_Options)
 * I’d like to avoid making this a “must-use” plugin as I want my end users to be
   able to chose to activate it or not.
 * Thanks!
 * [https://wordpress.org/plugins/bwp-recaptcha/](https://wordpress.org/plugins/bwp-recaptcha/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [bajro](https://wordpress.org/support/users/bajro/)
 * (@bajro)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multisite-master-api-keys/#post-4891656)
 * Hi,
 * We’ve created a function which sets recaptcha entry for every new blog (public/
   private keys and other options).
    Currently, with version 1.1.3 keypairs are 
   not automatically included for new blogs (WordPress multisite). For author (Khang
   Minh). Some of improvements that can be made with code below:
 *     ```
       <?php
   
       function cn_wpmu_create_blog ( $blog_id ) {
   
               global $wpdb;
   
               // get captcha private and public key from wp_options
               $wp_options = $wpdb->get_var("SELECT option_value FROM wp_options WHERE option_name LIKE 'bwp_capt_general'");
               $wp_options = unserialize($wp_options);
               $public_key = $wp_options['input_pubkey'];
               $private_key = $wp_options['input_prikey'];
   
               $default_bwp_settings = array(
                               'input_pubkey'          => $public_key,
                               'input_prikey'          => $private_key,
                               'input_error'           => '<strong>ERROR:</strong> Incorrect or empty reCAPTCHA response, please try again.',
                               'input_back'            => 'Error: Incorrect or empty reCAPTCHA response, please click the back button on your browsers toolbar or click on %s to go back.',
                               'input_approved'        => '1',
                               'enable_comment'        => 'yes',
                               'enable_registration'   => 'yes',
                               'enable_login'          => '',
                               'enable_akismet'        => '',
                               'use_global_keys'       => '',
                               'select_cap'            => 'manage_options' ,
                               'select_cf7_tag'        => 'bwp-recaptcha' ,
                               'select_response'       => 'redirect',
                               'select_position'       => 'after_comment_field' ,
                               'select_akismet_react'  => 'hold',
                               'hide_registered'       => '',
                               'hide_cap'              => '',
                               'hide_approved'         => ''
                       );
   
               $default_bwp_settings = serialize($default_bwp_settings);
   
               $wpdb->insert(
                       'wp_' . $blog_id . '_options',
                       array(
                               'option_name' => 'bwp_capt_general',
                               'option_value' => $default_bwp_settings,
                               'autoload' => 'yes'
                       )
               );
   
       }
   
       add_action ( 'wpmu_new_blog', 'cn_wpmu_create_blog' );
       ```
   
 * It would be ideal if you can make a check for keypairs (i.e. if they are exist
   in wp_config),
    set warnings in blogs defined language (WPLANG in wp_$blogid_options),
   make checkboxes (on user interface) for all options if global keypairs are used.
 * Thanks,
    Bajro
 *  Plugin Author [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * (@oddoneout)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/multisite-master-api-keys/#post-4891657)
 * Hmm currently any sub-blog will use the same key as the main blog, unless otherwise
   specified so I’m not sure if this is needed?
 * See BWP_RECAPTCHA::init_recaptcha_keys()
 *  [bajro](https://wordpress.org/support/users/bajro/)
 * (@bajro)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/multisite-master-api-keys/#post-4891658)
 * Unfortunately, this doesn’t work in our case. When a new blog is created, there
   is no row in database for recaptcha with name “_bwp\_capt\_general_” (and “_bwp\
   _capt\_version either_“) for that new blog.
    When you click “BWP reCAPT” on user
   interface, that creates above mention rows in database (table wp_$blogid_options),
   but without global keypairs. Can you check plugin (version 1.1.3) with multisite
   enviroment?
 * We have upgraded plugin with every new release, but with 1.1.3 that multisite
   feature doesn’t work anymore. Last version that worked was 1.1.0 (but in that
   version keypairs was stored differently).
 *  Plugin Author [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * (@oddoneout)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/multisite-master-api-keys/#post-4891659)
 * That’s weird because nothing related to multisite has been changed since 1.1.0.
   What you mentioned about missing option rows is expected as they are only created
   when needed, so a new blog should always use your network’s key pair by default
   unless you set one for that blog.
 * I will recheck this.
 *  [edik](https://wordpress.org/support/users/plocha/)
 * (@plocha)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/multisite-master-api-keys/#post-4891661)
 * I have the same problem. It affects many subblogs. New blogs and old blogs. Some
   of them use the global keys, others don’t use the global keys. I don’t know why.
 * If I check the ‘use global keys’ check box of a blog which isn’t using global
   keys and press enter, it has no effect. The blog still doesn’t use the global
   keys.
 *  [bajro](https://wordpress.org/support/users/bajro/)
 * (@bajro)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/multisite-master-api-keys/#post-4891662)
 * > I will recheck this.
 * Can we do something more?
    If you want, you can contact me in PM and I’ll give
   you access so you can test it out.
 * Thanks

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Multisite Master API Keys’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/bwp-recaptcha.svg)
 * [Better WordPress reCAPTCHA (with no CAPTCHA reCAPTCHA)](https://wordpress.org/plugins/bwp-recaptcha/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bwp-recaptcha/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bwp-recaptcha/)
 * [Active Topics](https://wordpress.org/support/plugin/bwp-recaptcha/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bwp-recaptcha/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bwp-recaptcha/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [bajro](https://wordpress.org/support/users/bajro/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/multisite-master-api-keys/#post-4891662)
 * Status: not resolved