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:

Launching Your WordPress Site: A Step-by-Step Guide for Entrepreneurs | WPRiders Article
Launching Your WordPress Site: A Step-by-Step Guide for Entrepreneurs
Starting a website can feel like jumping into the deep end if you don’t know how to swim. Between picking a domain, finding a web host, installing WordPress, and customizing your site, it’s enough to make even tech-savvy entrepreneurs feel overwhelmed. That’s why launching your WordPress site the right way matters—it sets the tone for everything that […]
Considerations for Enterprise WordPress Development - WPRiders Article
Considerations for Enterprise WordPress Development
Enterprise WordPress development is often overlooked by large organizations due to outdated assumptions—but it’s time to challenge that thinking. In fact, it’s known that enterprises need flexible, secure, and future-proof platforms to stay competitive. That’s why WordPress, with its massive global adoption and open-source strength, has quietly evolved into exactly that. From powering global newsrooms to […]
What Can You Build With WordPress? - WPRiders Article
What Can You Build With WordPress?
In today’s world, having a business and no website is like trying to drive a car with no engine. Sure, you can reach your destination if you get out and push your car, but wouldn’t it be a lot easier if you just had the engine in the first place? That’s the power of having the […]