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

You Might Also Enjoy These Digital Marketing Articles:

How to Choose a WordPress Management Agency
Building a successful online business on WordPress takes effort. It requires time, focus, and flexibility. You’re serious about your business. Then, a WordPress management agency is recommended. They handle your website. You focus on growth. But how to choose a WordPress management agency? That’s a key decision. Find a partner that matches your needs. WordPress Management […]
WordPress Security in Focus: Building Trust With Your Customers
With over 43% of all websites powered by WordPress as of August 2023, it’s no wonder this CMS dominates with over 60% of the global market share. Its popularity and open-source system make it the go-to choice for many businesses and organizations. However, these same reasons also make WordPress a lucrative target for hackers looking […]
How to Choose a WordPress Design Agency - WPRiders Article
How to Choose a WordPress Design Agency
Choosing the right WordPress design agency is crucial when creating a website that will be your business forefront. A good website should bring visitors and help convert these visitors into customers for your business. With design agencies for WordPress, many options are available, but this doesn’t mean all are good for you. So deciding which […]