The MU forums have moved to WordPress.org

Math Comment Spam Protection Plugin Help (9 posts)

  1. Romik84
    Member
    Posted 17 years ago #

    Hi there,

    I would like to use the Math Comment Spam Protection Plugin http://sw-guide.de/wordpress/plugins/math-comment-spam-protection/ in my blog network and have it activated automatically when a new blog is created.

    The issue is when a new blog is activated the plugin is active as well but it needs my action to Save options otherwise it writes an error in the comment form. Is there any way to fix it? Thanks for help.

  2. cafespain
    Member
    Posted 17 years ago #

    From the sounds of things, it is creating the defaults for display in the options panel, but not saving them until you press the submit button.

    In which case you'll have to move the defaults to the installation routine, or do an installed check and then add them if one of the settings isn't present.

    Maybe try contacting the author if you don't feel up to doing it yourself.

  3. tdjcbe
    Member
    Posted 17 years ago #

    If you know what needs to be saved, do a forum search for 'new blog defaults' as there's a couple of plugin frameworks that should show you how to save data upon blog creation.

  4. Romik84
    Member
    Posted 17 years ago #

    Hm, I think I've not found any solution in the forum which would solve my issue, no such plugin.

  5. cafespain
    Member
    Posted 17 years ago #

    Yes there is and it's the top result when you search the forum for the text that tdjcbe gave you.

  6. Romik84
    Member
    Posted 17 years ago #

  7. cafespain
    Member
    Posted 17 years ago #

    Yes, so now take that plugin, look in the code of the plugin you have and see where it saves the settings for the options form.

    Takes those settings and put it in the location specified so that the defaults are set up automatically when a new blog is created.

    Or.. contact the author of the plugin and ask whether they could change their plugin to create the defaults in the first place (like I said in the first reply).

  8. Romik84
    Member
    Posted 17 years ago #

    before I contact the author could you help me to try to out with the defaults? I found something like this in the plugin: `function mcsp_options_subpanel() {

    /* Lets add some default options if they don't exist
    If an option with the specified name already exists, no changes are made to its value
    or to the database as a whole. add_option() can only add options, not alter them.*/

    $tmp_noanswer = '<p align="center">
    Error: Please press the back button and fill the required field for spam protection.
    </p>';
    $tmp_wronganswer = '<p align="center">
    Error: You have entered the wrong sum in the spam protection field.

    Press the back button and try again.
    </p>';
    $optionarray_def = array(
    'mcsp_opt_numbers' => '1~1, 2~2, 3~3, 4~4, 5~5, 6~6, 7~7, 8~8, 9~9, 10~10',
    'mcsp_opt_msg_no_answer' => $tmp_noanswer,
    'mcsp_opt_msg_wrong_answer' => $tmp_wronganswer,
    'mcsp_opt_fieldname_useranswer' => 'mcspvalue',
    'mcsp_opt_fieldname_mathresult' => 'mcspinfo',
    );
    add_option('plugin_mathcommentspamprotection', $optionarray_def, 'Math Comment Spam Protection Plugin Options');

    /* Check form submission and update options if no error occurred */
    if (isset($_POST['submit']) ) {
    ### SECURING FORMS ###
    if ( function_exists('current_user_can') && !current_user_can('manage_options') )
    die(__('Cheatin’ uh?'));
    check_admin_referer( $mcsp_nonce );
    ### SECURING FORMS ###

    $optionarray_update = array (
    'mcsp_opt_numbers' => mcsp_aux_numbers_input_formatting($_POST['mcsp_opt_numbers']),
    'mcsp_opt_msg_no_answer' => $_POST['mcsp_opt_msg_no_answer'],
    'mcsp_opt_msg_wrong_answer' => $_POST['mcsp_opt_msg_wrong_answer'],
    'mcsp_opt_fieldname_useranswer' => mcsp_aux_fieldname_formatting($_POST['mcsp_opt_fieldname_useranswer']),
    'mcsp_opt_fieldname_mathresult' => mcsp_aux_fieldname_formatting($_POST['mcsp_opt_fieldname_mathresult'])
    );
    update_option('plugin_mathcommentspamprotection', $optionarray_update);

    }

    /* Get options */
    $optionarray_def = get_option('plugin_mathcommentspamprotection');`

    what should I use then in the WPMU new blog settings plugin from that lines. Thanks.

  9. Romik84
    Member
    Posted 17 years ago #

    Should it look something like this?

    function newblogd_def() {

    $optionarray_update = array (
    'mcsp_opt_numbers' => mcsp_aux_numbers_input_formatting($_POST['mcsp_opt_numbers']),
    'mcsp_opt_msg_no_answer' => $_POST['mcsp_opt_msg_no_answer'],
    'mcsp_opt_msg_wrong_answer' => $_POST['mcsp_opt_msg_wrong_answer'],
    'mcsp_opt_fieldname_useranswer' => mcsp_aux_fieldname_formatting($_POST['mcsp_opt_fieldname_useranswer']),
    'mcsp_opt_fieldname_mathresult' => mcsp_aux_fieldname_formatting($_POST['mcsp_opt_fieldname_mathresult'])
    );
    update_option('plugin_mathcommentspamprotection', $optionarray_update);
    }

    add_action('wpmu_new_blog', 'newblogd_def');

About this Topic