I'm looking for a way to programmatically enable and disable TinyMCE buttons depending on custom user rights (or other criteria for that matter).
I can't seem to find any example code on this. The easiest way would ofcourse be if it would be possible to put code directly at the plugin .cs-class.
Anyone done this?
Great question - and I've asked myself before as well. I'm sure in old-style pre-TinyMCE we had some options for this, but in the modern happy world we can't restrict by users. As you know, you can restrict on specific properties or global, but that's not helpful really!
I did play around with a custom non-visible button which was injected by a TinyMCE plugin .cs which then ran some funky code to check the user and show/hide buttons client-side. It worked, but was very hacky and nasty and I wouldn't recommend it. If you can get something like that working then do let me know!
Effectively, we have to think laterally. We can't restrict on the button plugin itself per se, but we can inject some script which can then work some magic afterwards.
If anyone has a better solution please do share it because this is a requirement that crops up often when I'm helping partners on pitches!
Not sure if it helps but I have a potential solution in a thread a few weeks ago. Nothing fancy, but perhaps a way forward:
Hello Dan and Linus,
thanks for your replies. I will take a look at the link you suggested, Linus.