Viewing 6 replies - 1 through 6 (of 6 total)
  • 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

    (@oddoneout)

    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()

    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

    (@oddoneout)

    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.

    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.

    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.