Select Page

When editing a user profile on a ClassicPress website, there are a great many inputs. Do your users fill in all those values? It’s likely that most will leave a lot of empty fields. Surely, nobody needs a field for Google+ in 2019. The good news is that you can hide any input on the profile editing page with very little effort.

Using PHP and CSS to Remove Profile Sections

Before moving on, it’s important to note that this technique is hiding the unneeded inputs with CSS. That means those inputs are not disabled or prevented – they are simply hidden from sight. If you need to remove items programmatically before the page is generated, this technique will not meet your needs.

So, where does the PHP come in, then,” you might be wondering? Good question. The PHP is used to ensure that your custom style sheet is only loaded for the profile editing page.

And just where is all this CSS and PHP supposed to go,” you probably want to know? Another good question. In order to add random internal functionality to your website, you should use a utility plugin to house the code. It’s likely that you already have a utility plugin, but, if not, take a few minutes to build one – you will find it incredibly handy.

Enqueue the Style Sheet

In your utility plugin’s PHP file, add the following few lines of code. To put it simply, the code is saying, “if we’re on the profile editing page, load the style sheet…but load it nowhere else.”

Create the Style Sheet

Any (or all) of the CSS rules below can be added to your custom style sheet. Following from the PHP code above, you would be saving the CSS file to /styles/custom.css in your utility plugin.

You can hide whichever fields will meet your needs; the page will still function properly. If you were to copy the entire style sheet below into your plugin, it would render the profile editing page as a blank canvas. It is notable that these styles will apply only to the core sections – if a plugin has added extra tables or sections to the page, these rules may not work on those.

Wrapping Up

With very little PHP and CSS you can customize the user profile editing page in ClassicPress. This can give your users a more streamlined experience and doesn’t require any “expensive” operations to remove the items. What’s not to love?!

What do you think?

Did you realize all these fields could be hidden with CSS? Were you looking at complicated output buffering or string replacement solutions to customize the page? Or, were you just dealing with it? I’m curious to hear your thoughts – let me know in the comments!