Removing “Website” Field from the contact info

Revisited and updated answer:

We can’t use the user_contactmethods filter to remove the website wrapper, because this piece is hardcoded in the user-edit.php file and not part of the filterable user contacts loop, generated by:

wp_get_user_contact_methods( $profileuser )

Hiding it with CSS

The website row element now got it’s own .user-url-wrap class:

<tr class="user-url-wrap">
    <th><label for="url"><?php _e('Website') ?></label></th>
    <td>
        <input type="url" name="url" id="url" 
               value="<?php echo esc_attr( $profileuser->user_url ) ?>" 
               class="regular-text code" />
    </td>
</tr>

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:

function remove_website_row_wpse_94963_css()
{
    echo '<style>tr.user-url-wrap{ display: none; }</style>';
}
add_action( 'admin_head-user-edit.php', 'remove_website_row_wpse_94963_css' );
add_action( 'admin_head-profile.php',   'remove_website_row_wpse_94963_css' );

Hiding other fields

There are similar row classes:

tr.user-{field}-wrap

available for the fields:

admin-color,
comment-shortcuts,
admin-bar-front,
user-login,
role,
super-admin,
first-name, 
last-name, 
nickname, 
display-name, 
email,
description, 
pass1, 
pass2, 
sessions, 
capabilities,
...

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:
Before


After removing the website row:
After

1 thought on “Removing “Website” Field from the contact info”

Leave a Comment