Add html comments using newly created user role

Marius Vetrici
CEO wpriders
Date
June 17, 2015

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 🙂

Struggling to get a product out the door?

Let's talk about how we can help!

Let's talk about how we can help!

Leave a reply

Your email address will not be published.

Your email address will not be published. Required fields are marked *

Struggling to get a product out the door?

Want More Amazing Stories?
Sign up now and get the best business as well as technical advice on how to run your WordPress powered business:
  • This field is for validation purposes and should be left unchanged.