0

I am using a plugin that is adding a filter that I don't want. So I want to remove the filter. Their code is as follows:

class GF_ScheduleExportEntries extends GFFeedAddOn {
    public function init() {
        parent::init();
        add_filter('gform_form_list_columns', array($this, 'gform_form_list_columns'), 10, 1 );
    }

    // This is what I want to remove
    public function gform_form_list_columns($columns){
        $columns['gfsee_export'] = esc_html__( 'Export', $this->_slug );
        return $columns;
    }
}

$gfexpe_instance = new GF_ScheduleExportEntries();

register_activation_hook( __FILE__, array(&$gfexpe_instance, 'plugin_activate'));

register_deactivation_hook( __FILE__, array(&$gfexpe_instance, 'plugin_deactivate') );

I have tried doing the following, which doesn't seem to work:

add_action( 'plugins_loaded', 'gwu_remove_plugin_filter' );
function gwu_remove_plugin_filter() {
    global $GF_ScheduleExportEntries;
    remove_filter('gform_form_list_columns', array($GF_ScheduleExportEntries, 'gform_form_list_columns'), 99);
}

Any suggestions?

13
  • I think the priorities need to match, i.e. you need to use 10 not 99. However that might not be enough either.
    – Rup
    Sep 14 at 22:13
  • Didn't help. Thanks for trying, though.
    – Mr Gandy
    Sep 14 at 22:16
  • Where/how is GF_ScheduleExportEntries instantiated? You need to use the same instance when removing. Sep 14 at 23:07
  • 1
    E.g. someone once asked a Q similar to this with Yoast SEO and spent days trying to figure out how to modify a class to remove something without explaining why. Once they explained what they actually wanted, someone pointed out it was a checkbox on a settings page
    – Tom J Nowell
    2 days ago
  • 1
    Also, the official docs for that filter show how to remove columns docs.gravityforms.com/gform_form_list_columns
    – Tom J Nowell
    2 days ago