• Moderator Marius L. J.

    (@clorith)


    Hi,

    I stumbled upon an interesting limitation in some scenarios with cf7 and the Beaver Builder plugin, which I would like to solve in a more elegant way than I currently am (I’m right now using MU plugins, without any real filters).

    The scenario:
    When using the Beaver Themer, a tool for creating page templates for various posts or pages that match given criterias, the in_the_loop() returns false, because the post content is fetched using a secondary WP_Query(). This makes cf7 not populate the _wpcf7_container_post field.

    My current “solution”:
    A mu-plugin has been created, which uses the existing wpcf7_form_hidden_fields filter to add my own field which uses get_the_ID(), and then I look for $_POST['_wpcf7_container_post'] entries that have the value 0, and override it with my own form field from the filter.

    Proposed solution:
    includes/contact-form.php:466 already has the wpcf7_form_hidden_fields filter, but this just appends new entries to the fixed set of fields cf7 provides.

    It would be great if a filter was implemented that allowed overriding the built in ones in some scenarios. I see no immediate drawback by passing $hidden_fields, instead of an empty array, to the wpcf7_form_hidden_fields filter, since this already expects an array, and those extending it have not been able to touch the array keys that were pre-defined by cf7 until now either.

    
    $hidden_fields += (array) apply_filters(
    			'wpcf7_form_hidden_fields', $hidden_fields );
    
    

    Alternatively, implementing a new filter following this, if there are backwards compatibility concerns

    
    $hidden_fields += (array) apply_filters(
    			'wpcf7_form_hidden_fields', array() );
    $hidden_fields = (array) apply_filters(
    			'wpcf7_form_all_hidden_fields', $hidden_fields );
    
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Request for new filters’ is closed to new replies.