0

Does anyone know how I can remove the Twitter and Google Plus profile fields from my functions.php? This is the code that I am using:

function modify_contact_methods($profile_fields) {
    unset($profile_fields['twitter']);
    unset($profile_fields['googleplus']);
    unset($profile_fields['url']);

    return $profile_fields;
}
add_filter('user_contactmethods', 'modify_contact_methods');

Usually, unset() would hide the fields, but all of the fields are still there. I have been able to add additional fields, but not remove any of the preset fields. I am trying to remove some fields and move others (Twitter and Google Plus) to another section just for social media profiles. I know that this isn't conflicting as only Twitter is in this section, not Google Plus and neither of them are hidden. When I've been looking on Google, results show me the unset() function, or a jQuery hiding function. I want these removed completely.

For your information, I am using Wordpress version 4.0.

1

These are not default fields added by Wordpress. They have to be added via a theme or plugin. You will need go and check where these fields are added.

I would speculate that there are some kind of priority set when these fields are registered. You need to add a lower priority (higher number) to your filter function to make sure that your filter function runs after these fields are registered. As this stage your filter function is executed first before these fields are set

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.