Schedule a Free Consultation
Add html comments using newly created user role

Add html comments using newly created user role

Read Article

I was recently working on a piece of code that will:

  • create as special user role
  • allow that user role to insert HTML comments on posts (specifically we needed images and links) from wp-admin

If I was commenting like admin, all was good – the comment with image was getting published. But if instead I was commenting using that user role, unfortunately all the HTML got stripped.

After some debugging inside WordPress, I found the culprit, which, by the way, it’s a feature of WordPress – the unfiltered_html capability for my user role. Basically if you have a newly defined user role that you want to be able to insert HTML in comments, you have to add that capability to your new user role. Here’s the simple snippet:

Once again, the best documentation for WordPress is the actual source code.

Follow the code and you will see the light 🙂

Navigate to

Check some other articles we wrote

How to Choose a WordPress Expert for Your Website
While WordPress is a user-friendly platform for creating simple websites, things can quickly become complex when starting a business website. Custom functionalities, complicated platform integrations, cybersecurity, compliance, and optimizations are all critical factors you must consider. A WordPress expert can provide expert guidance, support, and services to help businesses navigate these complexities and create a […]
How To Pick Website Photos That Make Your Website Look More Professional
Learn nine simple tricks the pros use to pick better website photos and make your website look more professional
WordPress Maintenance Package – What should it include?
WordPress maintenance packages and plans come in different shapes and sizes. Each WordPress maintenance agency offers different services tailored to their customer needs.  For instance, if you are running an eCommerce website, you need close attention to Woocommerce maintenance, payment providers, and ERP integration. At the same time, if you run a local services business, […]