I want to remove the website field from the user contact info. I use the following to remove the AIM,Jabber and Yahoo IM . But I am not able to use this to remove the website. Someone please help.
function remove_contactmethods( $contactmethods ) {
unset($contactmethods['aim']);
unset($contactmethods['yim']);
unset($contactmethods['jabber']);
return $contactmethods;
}
add_filter('user_contactmethods','remove_contactmethods',10,1);
Revisited and updated answer:
We can’t use the
user_contactmethods
filter to remove the website wrapper, because this piece is hardcoded in theuser-edit.php
file and not part of the filterable user contacts loop, generated by:Hiding it with CSS
The website row element now got it’s own
.user-url-wrap
class:Previously we had to use jQuery, to target the parent row of the
#url
field, for removal.But now we can easily target the website wrapper and hide it with CSS:
Hiding other fields
There are similar row classes:
available for the fields:
including all the fields from the dynamic user contacts methods.
Here we just replace the
{field}
part with the corresponding field name.Screenshots
Before removing the website row:
After removing the website row:
I resolved the problem with ob_ functions and DOMDocument. It’s better than jQuery or CSS for protecting the form.
I use this kind of solution every time when I can’t access a part of HTML content through a hook.
Expanding on @birgire’s and justifying @Patricia Walton’s answer, if you only add
add_action('admin_head-user-edit.php','remove_website_row_wpse_94963');
it will only be gone from the page where admin is editing a profile. To also make it disappear when a user edits its own profile add also
add_action('admin_head-profile.php','remove_website_row_wpse_94963');
, like this:The code was not working for me either, but changing the add_action to point to profile.php did work.
Expanding on @birgire’s answer, I wrote this into an array so it’s a little easier to read: