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:

Top 10 WordPress Stats and Facts Every CFO Should Know - WPRiders Article
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 […]
Top 10 Premium WordPress Membership Plugins for 2024 - WPRiders Article
Top 10 Premium WordPress Membership Plugins for 2024
As we enter 2024, the role of membership plugins in enhancing website functionality has become even more important, especially for WordPress custom development projects. These top 10 WordPress membership plugins streamline subscription management, restrict content access, and promote user engagement to help membership websites thrive. 2024’s Best Premium WordPress Plugins to Take Your Website to […]
How to Launch a Job Website Using WordPress [Complete Guide] - WPRiders Article
How to Launch a Job Website Using WordPress [Complete Guide]
We’ve All Been There… Even You I don’t know about you, but I was really excited about my first job. It was the end of my freshman year in college, and I wanted to find summer work. That’s why I started job hunting early. And if there’s one thing I learned, it’s that finding a […]