By default, WordPress user profiles include fields such as Email, Website, and other optional information. If you want to simplify the profile page or prevent users from editing certain fields, you can hide them using CSS or PHP hooks. On ruachost.com, this is a safe way to streamline the admin experience without modifying core WordPress files.

 

Why Hide Profile Fields?

  • Simplifies the user interface for site contributors.

  • Prevents confusion by removing unused fields.

  • Enhances security by limiting exposure of unnecessary data.

 

Method 1: Hide Fields with CSS (Recommended)

  1. Log in to WordPress as administrator.

  2. In the dashboard, go to Appearance → Theme Editor.

  3. Select your active theme and open the functions.php file.

  4. Add the following code snippet:

    function hide_user_profile_fields_css() {
        echo '<style>
            tr.user-url-wrap { display: none; } /* Hides Website field */
            tr.user-description-wrap { display: none; } /* Hides Biographical Info field */
        </style>';
    }
    add_action('admin_head-user-edit.php', 'hide_user_profile_fields_css');
    add_action('admin_head-profile.php', 'hide_user_profile_fields_css');
    
  5. Click Update File.

  6. Refresh the user profile page → The selected fields will be hidden.

 

Method 2: Remove Fields with PHP (Advanced)

Instead of hiding fields visually, you can remove them entirely:

function remove_contact_methods($contactmethods) {
    unset($contactmethods['url']);        // Removes Website field
    unset($contactmethods['description']); // Removes Biographical Info field
    return $contactmethods;
}
add_filter('user_contactmethods', 'remove_contact_methods');
 

Important Notes

  • Always back up your theme files before editing.

  • Use a child theme to preserve changes during updates.

  • Avoid editing user-edit.php directly use hooks or CSS instead.

  • Test changes to ensure they don’t affect admin functionality.

 
Răspunsul a fost util? 0 utilizatori au considerat informația utilă (0 Voturi)

Powered by WHMCompleteSolution