Useful

2017.11.09

How to remove WordPress admin Profile page fields (Including Personal Options, Biographical Info, Website etc.) and titles without JS

In categories: Tutorials, Website development, Wordpress

Recently had been working on this project of mine where I came upon a problem – how to remove WordPress admin Profile page fields and titles that will not be needed for users who will be using the new system.

You do not want your users to be confused with information that they don’t have to input therefore it might be a good idea to remove them. And I mean removing them since hiding is not an option and it involves CSS or JS solution that makes those fields and titles disappear after the page has loaded and it means that the user gets to see some flickering in the fields.

Here is the final result of my Profile page:

In my case I needed the following fields and titles to be removed from the WordPress admin Profile page:

  • “Personal Options” title
  • “Visual Editor” checkbox (Disable the visual editor when writing)
  • “Keyboard Shortcuts” checkbox (Enable keyboard shortcuts for comment moderation)
  • “Name” title
  • “Toolbar” checkbox (Show Toolbar when viewing site)
  • “Nickname” field (which is required therefore it still has to be hidden not removed)
  • “Display name publicly as” dropdown
  • “Contact Info” title
  • “Website” field
  • “About Yourself” title
  • “Biographical Info” textarea field
  • “Profile Picture” image

I searched the internet all over and wanted to find a solution that would be based on WordPress hooks and wold allow me to unset or alter the output of the Profile page but with no luck. In the end I came across a solution that hooks into the output of the admin Profile page and allows you to use preg_replace function in order to cut out information that is not needed.

Since the structure of the page is laid out in tables and rows, I had to base the preg_replace function on table row classes and heading content had to be used in order to find them and replace them with nothing. Yes, this is not a beautiful solution and it will work until WordPress doesn’t change the classes or structure of the Profile page but that usually doesn’t happen so often.

So here is the solution How to remove WordPress admin Profile page fields (Including Personal Options, Biographical Info, Website etc.) and titles without JS. Simply copy and paste it in your functions.php file:

So this does the trick and removes fields from admin Profile page but we are not able to remove the nickname field like this since it is mandatory. So for this I am still using the solution with JS like so:

And the only thing that could be removed via hook was Admin color scheme and it is done like so:

Let’s hope that WordPress team will soon create hooks that will easily allow us to change the admin Profile page but for now this is what worked for me beautifully. No need to hide the fields using Javascript, just use the above code and throw out the lines you do not wan’t to be removed.

Other posts

Your thoughts

 

Latest work