Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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);
share|improve this question

3 Answers 3

up vote 9 down vote accepted

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

share|improve this answer
3  
You should use .remove() instead of .hide() –  Bainternet Apr 8 '13 at 7:18
    
This is not working for me. This code should be put in finctions.php right?? –  MidhuN Apr 8 '13 at 7:25
    
You have to be a non-admin when you test it or comment out the if sentence with the capability test. It works in functions.php, but I think it's better to have it in a plugin so you don't loose it when you change the theme. –  birgire Apr 8 '13 at 7:34
1  
thanks @Bainternet, I updated the code. –  birgire Apr 8 '13 at 7:37
    
How about this apply_filters( "user_{$name}_label", $desc ); –  Brad Dalton Jul 10 at 22:51

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:

function remove_website_row_wpse_94963() {
    if(!current_user_can('manage_options')){
        // hide only for non-admins
        echo "<script>jQuery(document).ready(function(){jQuery('#url').parents('tr').remove();});</script>";
    }
}
add_action('admin_head-user-edit.php','remove_website_row_wpse_94963');
add_action('admin_head-profile.php','remove_website_row_wpse_94963');
share|improve this answer

The code was not working for me either, but changing the add_action to point to profile.php did work.

function remove_website_row_wpse_94963() {
    if(!current_user_can('manage_options')){
        // hide only for non-admins
        echo "<script>jQuery(document).ready(function()    
            {jQuery('#url').parents('tr').remove();});</script>";
    }
}

add_action('admin_head-user-edit.php','remove_website_row_wpse_94963');
share|improve this answer
    
I can't see in what the code you posted differe form @birgire one. –  gmazzap Sep 2 '13 at 18:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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