• After searching high and low and with no luck finding a working option, I finally discovered a way to hide some of the profile fields that do not have a hook. Just to be clear, I am already using some code that removes the biography section and hides the color selector area so make sure you take a look at your source code to get the right counts.

    By using the jQuery eq selector, you can hide pretty much anything on your page. I am only hiding fields that I do not want my non-admins to see so this is the code that works for me in case anyone else needs something like it:

    function remove_profile_fields() {
    	if(!current_user_can('update_core')) {
    ?>
    	<script type="text/javascript">
        jQuery(document).ready( function($) {
      	$("tr:eq(7)").hide();
    	$("tr:eq(8)").hide();
    	$("tr:eq(10)").hide();
       	});
        </script>';
    
    <?php }
    }
    
    add_action('admin_head', 'remove_profile_fields');

    If you don’t understand how the eq selector works, this is a simple rundown….for example: tr:eq(0) would select the very first table row on the page, tr:eq(1) would select the second and so on. Just look at your source code and count down how many rows are on the entire page to get your number.

    Additional note: I first used .remove() instead of .hide() and that affects your row count so it is easier for me to use .hide().

    Hopefully someone else can benefit from my hours and hours of wracking my brain.

  • The topic ‘Remove Nickname, Display Name, and Website from Profile Page’ is closed to new replies.