0

I am trying to edit a filter that is added from a plugin, without editing the plugin itself. The plugin in question is Gravity Forms User Registration.

I have found the filter function in the plugin code, and I am currently trying to remove it in order to add it again with my changes. However, I can't figure out how to remove the filter. When removing actions, i usually hook in to the same hook with a lower priority and remove it from there. However, this seems different.

Filter is added like this:

/**
 * Initializes GFAddon and adds the actions that we need
 *
 * @see GFAddon
 */
public function init() {

[...]
    add_filter( 'gform_validation',                   array( $this, 'validate' ) );
[...]

Should I create a new instance of something for '$this', and how do I from which hook to call my removal function?

0

Just a hint...

In your case, I'll try to remove the filter

remove_filter( 'gform_validation', array( 'classname', 'validate' ) );

Rename classname with the class name where the filter is.

And add your filter and functions

add_filter( 'gform_validation', 'your_validate' ) );

If you want to access to another class (and public function) : classname::validate();

Hope it helps

  • Thanks. But how do I figure out the classname? – user2806026 Nov 9 '16 at 14:33
  • at the top of the file where stand the public function class GFaddon{ ? – Benoti Nov 9 '16 at 14:38
  • Thank you very much for your reply. I cant get it to work though.. add_action('wp_head', 'test_remove'); function test_remove() { remove_filter( 'gform_validation', array( 'GF_User_Registration', 'validate' ) ); } I have tried with GF_User_Registration(), new GF_User_Registration() and $global GF_User_Registration as well.. – user2806026 Nov 10 '16 at 10:25
  • Try add_action('init' ... Instead of wp_head – Benoti Nov 10 '16 at 10:27
  • And remove_filter directly not in function ? – Benoti Nov 10 '16 at 10:34

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.