• Resolved netzgestaltung

    (@netzgestaltung)


    Hi there,

    In Version 5.9 CF7 added an enum validation added to dropdown menu fields and checkboxes – so dynamicly created values are invalid data for safety reasons.

    As a result the select(and probably also checkboxes) prefilled with taxonomy terms won’t get submitted.

    I checked https://stackoverflow.com/questions/78101215/contact-form-undefined-value-was-submitted-through-this-field and simply removing the new action does quickly reenable the form submitting but leaves securitiy issues.

    remove_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_select_enum_rules', 20, 2 );

    in the stackoverflow topic answer https://stackoverflow.com/a/78136065/1165121 is a more detailed way to add the dynamicly created values to the valid values so that part could be secured.

    add_action( 'wpcf7_init', 'wpwoodo_change_select_validation_rule', 99 );
    function wpwoodo_change_select_validation_rule() {
        remove_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_select_enum_rules', 20, 2 );
        add_action( 'wpcf7_swv_create_schema', function( $schema, $contact_form ) {
            $valid_values = [ 'value1', 'value2', 'value3' ];
            $schema->add_rule(
                wpcf7_swv_create_rule( 'enum', array(
                    'field'  => 'my_select_field_id',
                    'accept' => $valid_values,
                    'error'  => $contact_form->filter_message(
                        __( 'Undefined value was submitted through this field.', 'my-text-domain' )
                    ),
                ) )
            );
        }, 30, 2 );
    }

    maybe thats a feature request here…

    After the CF7 Update it looked like that – so something hat to be done:

    kind regards
    tom

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter netzgestaltung

    (@netzgestaltung)

    Yes it also is applicable for checkboxes which i quick-fixed with:

    
    remove_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_checkbox_enum_rules', 20, 2 );
    
    Plugin Author Aurovrata Venet

    (@aurovrata)

    thanks for reporting this Tom. I noticed this the other day.

    I will fix this on priority in the next release

    llcelinell

    (@llcelinell)

    Hello, I inserted the code in function.php but it doesn’t work for me for my checkboxes. I have many check boxes and I cannot remove the message that appears everywhere from the 5th box… Will the plugin update be released soon? Because I don’t want to downgrade the version…

    llcelinell

    (@llcelinell)

    ERRATUM => the code inserted in function.php works on the computer version of the form but not on the mobile version (cell phone) the error message is still present…

    my form : https://lesetoilesdumidi.com/process-nettoyage/

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Please use a separate thread for your issue, even if related to this one. This is WP forum policy and makes for easier readability by others seeking answers.

    Will the plugin update be released soon?

    yes, I have already fixed it on my dev server but need to complete the testing. I have been travelling lately and not had the time to test and release it.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    could you kindly check v6.1.0RC1 fixes your issue? it is available here in the GitHub repo.

    llcelinell

    (@llcelinell)

    Hello, thank you for your message. I’m sorry but I’m a very bad developer. I know how to update a plugin or insert a code somewhere when I’m given all the manipulation to do, but I don’t know what to do with the files. Sorry ??
    I still wanted to point out that ultimately, the code inserted in function.php also worked well on mobile, it’s just that it took a while before it worked. I remain at your disposal.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    simply download the zip file from the GitHub link above and manually update the plugin in your site. The plugin admin page has an option to upload a plugin from your computer file. Simply select the zip file.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I will take it that the test was successful. will make the release

    I’ve a select form field prefilled with the filter wpcf7_form_tag_data_option and the validation message also appears and the field is marked invalid.

    I’ve tried this snippets and there’s no way to disable the SWV rules.
    remove_action( ‘wpcf7_swv_create_schema’, ‘wpcf7_swv_add_select_enum_rules’, 20);
    remove_action( ‘wpcf7_init’, ‘reset_select_enum_rules’, 100);

    Next, I’ve a second select field that receives an AJAX request with the value of the first select and displays the result on it. It’s the same error.

    In my case, the version 6.1.0 is not working with my CF7 configuration.

    Any clues to resolve it?
    Thanks!

    Thread Starter netzgestaltung

    (@netzgestaltung)

    these snippets are regarded to a previous version, you should make your own thread to receive better help

    @netzgestaltung but the topic it’s the same, @aurovrata will decide if it’s better to create a new thread or condense all the information in this.

    The second snippet is a intent to remove the new code for the validation introduced in the 6.1.0 version.
    wp-content/plugins/post-my-contact-form-7/includes/class-cf7-2-post.php:243

    Thanks!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Hey @jpagano thanks for reaching out. @netzgestaltung is correct in pointing out the need to start a new thread. Even if the 2 are somewhat related, WP forum policy requires people start their own thread to make clearer and easier for other to follow.

    Please post your issue in a new thread and I will answer there. Thank you for your understanding ??

    I was able to get it working by using @netzgestaltung ‘s solution and calling it inside wpcf7 init

    add_action( 'wpcf7_init', function(){
    remove_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_checkbox_enum_rules', 20, 2 );
    });

    • This reply was modified 1 month, 2 weeks ago by WP Fix Fast.
    • This reply was modified 1 month, 2 weeks ago by WP Fix Fast.
Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.