Remove action within a class in a parent theme’s includes folder from the child theme

There’s a class in parent’s theme includes folder which adds action i want to remove in the child theme functions.php or in the plugin

class A {
public function __construct() {

add_action( ‘woocommerce_before_customer_login_form’, array( $this, ‘before_customer_login_form’ ) );

}

public function before_customer_login_form() {
echo ( ‘yes’ !== get_option( ‘woocommerce_enable_myaccount_registration’ ) ) ? ‘<div id=”customer_login” class=”woocommerce-content-box full-width”>’ : ”;
}
}

functions.php code inspired by solution from here

function remove_woo_forms_hooks() {
remove_action(‘woocommerce_before_customer_login_form’, array(‘A’,’before_customer_login_form’));
}

add_action( ‘after_setup_theme’, ‘remove_woo_forms_hooks’,0);

Though action removal doesn’t work. before_customer_login_form action is still fired.

Suspect that the code

remove_action(‘woocommerce_before_customer_login_form’,array(‘A’,’before_customer_login_form’));

is not correct.

How to remove the action correctly?

Read more here:: Remove action within a class in a parent theme’s includes folder from the child theme

Leave a Reply

Your email address will not be published. Required fields are marked *