Jump to content

TinyMCE config depending on user role


NikNak
 Share

Recommended Posts

Hi there

Is there a way to have different configurations of tinyMCE for different roles?

Basically, I want all the bells and whistles for a superuser, but only the basics for an editor. EG - a superuser can edit the html and add tables etc whereas the editor just has bold italic and heading or paragraph level.

This was a useful feature implemented in CMSMS (which I used to use).

Kind regards

Nik

  • Like 1
Link to comment
Share on other sites

I want to restrict the ability of users making a total mess of the pages they edit - hence a restricted config for TinyMCE.

If for example, on an occasion, they need a one off small table or some extra html within a page, it would be nice for me to be able to edit that page with the ability to access the html button of the editor. I absolutely don't want my clients getting at the html.

If the client then deletes it later or edits text within a table field, so be it.

This scenario has occurred in the past using the other CMS and caused no problem.

Regards

Nik

Link to comment
Share on other sites

The simplest way would be to modify config of InputfieldTinyMCE using a hook.

For example in the admin templates admin.php at the top:

wire()->addHookBefore('InputfieldTinyMCE::render', null, 'hookTinyMCE'); 

function hookTinyMCE(HookEvent $event) {
    $field = $event->object;
    if(wire("user")->isSuperuser()) {
        $field->set("theme_advanced_buttons1", $field->theme_advanced_buttons1 . ",|,code");
    }
}

Or alike in a autoload module.

I think it would be time to recive some flattrs from you :P

  • Like 1
Link to comment
Share on other sites

Hey Soma

That's a great solution - very much appreciated.  I am still working on my fist PW site (in 3 languages) and have to say I have no regrets about leaving the old CMS behind. I have learnt so much from the contributors on this forum. Now just need a bigger brain :-)

I havent heard of flattr - I'll go take a look.

Regards

Nik

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...