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
add comment

3 Answers

up vote 8 down vote accepted

Since the website field is hardcoded in the user-edit.php page and not part of the

_wp_get_user_contactmethods( $profileuser )

you can try to remove it with jQuery:

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');

where the website row is hidden for non-admins.


Before removing the website row: Before


After removing the website row: After

share|improve this answer
2  
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
add comment

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
add comment

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. –  G. M. Sep 2 '13 at 18:24
add comment

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.