I am trying to remove two contactmethods that were set by a plugin. I've read a lot about adding/removing an action, but found little on adding/removing a filter.

Original plugin code:

function pg_contactmethods( $contactmethods ) {
$contactmethods[ 'twitter' ]  = 'Twitter';
$contactmethods[ 'facebook' ] = 'Facebook';

unset( $contactmethods[ 'aim' ] );
unset( $contactmethods[ 'yim' ] );
unset( $contactmethods[ 'jabber' ] );

return $contactmethods;
add_filter( 'user_contactmethods', 'pg_contactmethods', 10, 1 );

I can comment out the Twitter and Facebook lines and that works, but I don't want to modify the original plugin.

I have create a functionality plugin and added the following line:

remove_filter( 'user_contactmethods', 'pg_contactmethods', 10, 1 );

Nothing changed.

Tried using just these two lines in a new function:

unset ( $contactmethods[ 'twitter' ] );
unset ( $contactmethods[ 'facebook' ] );

Nothing changed.

Tried the following remove_filter/add_filter in my functionality plugin:

remove_filter ('user_contactmethods', 'pg_contactmethods', 10, 1);
add_filter ('user_contactmethods', 'my_contactmethods', 10, 1);
function my_contactmethods( $contactmethods ) {
//$contactmethods[ 'twitter' ]  = 'Twitter';
//$contactmethods[ 'facebook' ] = 'Facebook';

unset( $contactmethods[ 'aim' ] );
unset( $contactmethods[ 'yim' ] );
unset( $contactmethods[ 'jabber' ] );

return $contactmethods;

Again, nothing changed.

Any advice on what I'm doing wrong?

Edit: I'm using WP 4.3.1, with a child theme.

1 Answer 1


My mistake was that I was trying to remove the plugin's filter from within my own plugin. In order to modify a plugin's filter, the remove_filter() function must be in the child theme's functions.php file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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