Schedule a Free Consultation
Add html Comments Using Newly Created User Role - WPRiders Article

Add html Comments Using Newly Created User Role

Read Article

I was recently working on a piece of code that needed to do the following:

  • Create a special user role
  • Allow that user role to insert HTML comments on posts—specifically, we needed support for images and links—directly from the WordPress admin panel

Everything worked perfectly when I tested it using an admin account. The comment included HTML content like images and links and displayed exactly as expected. However, when I switched to the new user role and tried the same thing, WordPress stripped out all the HTML.

The Issue With Adding HTML Comments

After some debugging inside WordPress, I found the issue. It wasn’t a bug—it was actually a default behavior of WordPress. By design, only certain user roles are allowed to add html comments. That’s because WordPress uses capabilities to control what users can do, and the ability to add html comments is tied to the unfiltered_html capability.

The Solution

If you’re unfamiliar with how WordPress handles user permissions, this guide on roles and capabilities is a great starting point. It explains how capabilities, like unfiltered_html, control what users can and can’t do—including whether they can add html comments.

So, if you’re building a custom role and want those users to add html comments without WordPress stripping out the tags, you need to ensure the right capabilities are in place. Once that’s done, your custom users will be able to leave rich, formatted comments just like an admin.

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

Follow the code and you will see the light 🙂

At WPRiders, we know your website isn’t just a project—it’s part of your business engine ⚙️. That’s why we offer more than just code.

If that sounds like what you need, 👉 Schedule a Free Discovery Call and let’s talk about your next move. We’re always up and ready for a good conversation.

Add html Comments Using Newly Created User Role - WPRiders Article

Navigate to

You Might Also Enjoy These Digital Marketing Articles:

Test If Flexslider Loaded
Test If Flexslider Loaded
Recently I had a mini project for a client and I had to test if Flexslider has been shown on the screen in order to further modify it. Subscribing to the startcallback didn’t work because the slider was shown by the theme and not by my code. jQuery(document).ready(…) didn’t work either. The slider was there, […]
Replace Comment Notification Email With Mandrill Template
Replace Comment Notification Email With Mandrill Template
Have you ever needed to replace the default email that WordPress is sending whenever a new comment is added? Recently I did. Here’s how I did it: To get this going you have to: Let me know if it worked for you.
Filter Custom Posts by Author in WP-Admin - WPRiders Article
Filter Custom Posts by Author in WP-Admin
Need to filter your Custom Post Types in WordPress by Author in WPAdmin? Here’s a handy way to do it by adding a new drop down for filtering: And here’s how it looks like: