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

Parsing email structure with IMAP functions
Have you ever had to parse the structure of an email, which contains html, text and images? Easier said than done 😅 As a developer, you need to examine the email content, extract images or text, and do something with them, like upload the images to the web server or save them to a database. […]
Best Hosting Providers When Starting Out With WordPress
When you go on vacation, do you book a hotel, or do you go for an Airbnb rental? I usually like renting either an apartment or a small house, and if you’re like me, then you’ll know how important picking a place with a good host is. Sure, the place you’ll be renting is also […]
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: 1) Install and configure WPMandrill plugin 2) Create a new template in your Mandrill account 3) Paste the php code in your […]