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

5 WordPress mistakes you’re making and how to solve them
Everybody makes mistakes. Maybe some of them might be small, like buying the wrong kind of milk, while others can be more serious, like forgetting to bring your gift to someone’s birthday party. Bottom line is that every single one of us makes mistakes. And to be honest, mistakes are not entirely bad. More often […]
Top 10 WordPress Stats And Facts Every CFO Should Know
A few years ago, I had a friend who was facing a pretty common business dilemma — she wanted a website for her business, but she didn’t have any programming skills. Knowing my background in web development, she came to me for some advice. That’s when I suggested that she try her hand at building […]
The Power of WordPress: Building Your Business Website with Ease
You used to need serious tech skills to build a professional website. But with WordPress, creating an online home for your business has never been easier. This wildly popular platform now powers over 43% of all websites—and it’s growing by over 500 new sites daily, compared to just 60-80 on competitor platforms such as Shopify […]