0

simple issue but i need some help because i dont why i m wrong on this...

The apply filter (Important, this is in construct Class):

       if ( apply_filters( 'tc_bridge_for_woocommerce_content_order_table_is_after', true ) == true ) {
            add_action(
                'woocommerce_email_after_order_table',
                array( &$this, 'tc_add_content_email_after_order_table' ),
                99,
                4
            );
        } else {
            add_action(
                'woocommerce_email_before_order_table',
                array( &$this, 'tc_add_content_email_after_order_table' ),
                99,
                4
            );
        }

I need to use the false from the conditionnal

so in my functions.php from my theme

function filter_after_setup_theme() {
    add_filter( 'tc_bridge_for_woocommerce_content_order_table_is_after', '__return_false' ); // move info ticket in email before order details
}
add_action('after_setup_theme', 'filter_after_setup_theme');

where i m wrong ?

thanks

0

Instead of adding the filter inside of the add_action(), you need to call the filter directly. You have this in your functions.php file:

function filter_after_setup_theme() {
    add_filter( 'tc_bridge_for_woocommerce_content_order_table_is_after', '__return_false' );
}

add_action('after_setup_theme', 'filter_after_setup_theme');

You are telling to WordPress to execute the filter when the action after_setup_theme happens (which is called before init hook, according to the Actions Hooks list).

Instead of the action, you should leave the filter to be registered alone, so instead of the previous code, you do this:

add_filter( 'tc_bridge_for_woocommerce_content_order_table_is_after', '__return_false' );

That filter will be registered in WordPress when the functions.php is loaded and not when the add_action('after_setup_theme', 'filter_after_setup_theme'); is executed.

If you still need to execute the filter inside a hook, I recommend to do it in init or maybe wp_loaded hooks.

  • Thank you but unfortunately with 'ini' or 'wp_loaded', it does not work too. I will contact the author of the plugin who forgot to put this filter in his doccumentation. Thank you. – WebMat Sep 6 at 6:24
0

My bad thing is resolved (@thanks to support of Tickera)

The add_filter must be used before the loading of plugins. (with custom plugin)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.