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 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 […]
Top 10 Most Common WordPress Myths Debunked by Specialists
During a recent conversation with a fellow entrepreneur, we somehow ended up talking about TV shows we both enjoy. One that came up wasMythBusters—there’s just something fun about watching a team use science to bust common myths we’ve all heard. That got me thinking about thetop 10 most common WordPress mythsthat many people still believe—and […]
Keyword Density Check: Fast and Accurate
The Keyword Density Check plugin provides the data needed to choose which keywords to associate with your post. When putting the final touches on your post, you frequently ask which keyword should you choose. Alternatively, you wonder whether your option for a keyword is really relevant to the post – some of the important decisions […]