hooks - Add filter return false not working

simple issue but i need some help because i dont why i m wrong on this...The apply filter (Important, this is in constru

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

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

Share Improve this question edited Sep 5, 2019 at 18:20 WebMat asked Sep 5, 2019 at 18:05 WebMatWebMat 331 silver badge6 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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.

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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745180061a4615377.html

相关推荐

  • hooks - Add filter return false not working

    simple issue but i need some help because i dont why i m wrong on this...The apply filter (Important, this is in constru

    11小时前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信